Fix blob naming logic
This commit is contained in:
parent
ac0b584ae0
commit
e864bdf5b0
@ -49,18 +49,21 @@ export const uploadPhotoFromClient = async (
|
||||
|
||||
export const convertUploadToPhoto = async (
|
||||
uploadUrl: string,
|
||||
photoId: string,
|
||||
photoId?: string,
|
||||
) => {
|
||||
const file = await fetch(uploadUrl)
|
||||
.then((response) => response.blob());
|
||||
|
||||
const fileName = photoId ? `${PREFIX_PHOTO}-${photoId}` : `${PREFIX_PHOTO}`;
|
||||
const fileExtension = getExtensionFromBlobUrl(uploadUrl);
|
||||
|
||||
if (file) {
|
||||
const { url } = await put(
|
||||
`${PREFIX_PHOTO}-${photoId}.${uploadUrl.split('.').pop()}`,
|
||||
`${fileName}.${fileExtension ?? 'jpg'}`,
|
||||
file,
|
||||
{
|
||||
access: 'public',
|
||||
addRandomSuffix: false,
|
||||
...photoId && { addRandomSuffix: false },
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user