mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	Complement file extension from MIME (#2979)
This commit is contained in:
		
							parent
							
								
									1af4f94338
								
							
						
					
					
						commit
						2f8cc36d4b
					
				
					 1 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -37,7 +37,13 @@ async function save(path: string, name: string, type: string, hash: string, size
 | 
			
		|||
	if (config.drive && config.drive.storage == 'minio') {
 | 
			
		||||
		const minio = new Minio.Client(config.drive.config);
 | 
			
		||||
 | 
			
		||||
		const [ext] = (name.match(/\.([a-zA-Z0-9_-]+)$/) || ['']);
 | 
			
		||||
		let [ext] = (name.match(/\.([a-zA-Z0-9_-]+)$/) || ['']);
 | 
			
		||||
 | 
			
		||||
		if (ext === '') {
 | 
			
		||||
			if (type === 'image/jpeg') ext = '.jpg';
 | 
			
		||||
			if (type === 'image/png') ext = '.png';
 | 
			
		||||
			if (type === 'image/webp') ext = '.webp';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		const key = `${config.drive.prefix}/${uuid.v4()}${ext}`;
 | 
			
		||||
		const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}.jpg`;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue