image upload content type
I'm trying to to set content type by a switch and it is taking ages to compelete. it is a switch within a for loop. so you can image the time it is taking.
is there a way to imporve this approach beside a if ... else if ... statements?
is there a way to imporve this approach beside a if ... else if ... statements?
let contentType = '';
switch (file.file.type) {
case 'image/png':
contentType = 'image/png';
break;
case 'image/jpeg':
contentType = 'image/jpeg';
break;
case 'image/jpg':
contentType = 'image/jpg';
break;
case 'image/webp':
contentType = 'image/webp';
break;
default:
console.error('Unsupported file type');
continue; // Skip unsupported file types
}
const { data: storagesData, error: storageError } = await supabase.storage
.from('images')
.upload(imgUrl, arrayBuffer, {
upsert: false,
cacheControl: null,
contentType: contentType
});let contentType = '';
switch (file.file.type) {
case 'image/png':
contentType = 'image/png';
break;
case 'image/jpeg':
contentType = 'image/jpeg';
break;
case 'image/jpg':
contentType = 'image/jpg';
break;
case 'image/webp':
contentType = 'image/webp';
break;
default:
console.error('Unsupported file type');
continue; // Skip unsupported file types
}
const { data: storagesData, error: storageError } = await supabase.storage
.from('images')
.upload(imgUrl, arrayBuffer, {
upsert: false,
cacheControl: null,
contentType: contentType
});