fix: improve storage file handling (#325)
- Improve storage files handling - Incremented version in package.json from 2.12.2 to 2.12.3. - Updated ImageUploader component to improve label and image styles, adding cursor pointer and transition effects for better user interaction.
This commit is contained in:
committed by
GitHub
parent
e0560a3685
commit
e6ecd63a59
@@ -118,26 +118,23 @@ async function uploadUserProfilePhoto(
|
||||
) {
|
||||
const bytes = await photoFile.arrayBuffer();
|
||||
const bucket = client.storage.from(AVATARS_BUCKET);
|
||||
const extension = photoFile.name.split('.').pop();
|
||||
const fileName = await getAvatarFileName(userId, extension);
|
||||
const fileName = getAvatarFileName(userId);
|
||||
const { nanoid } = await import('nanoid');
|
||||
const cacheBuster = nanoid(16);
|
||||
|
||||
const result = await bucket.upload(fileName, bytes, {
|
||||
contentType: photoFile.type,
|
||||
upsert: true,
|
||||
});
|
||||
|
||||
if (!result.error) {
|
||||
return bucket.getPublicUrl(fileName).data.publicUrl;
|
||||
const url = bucket.getPublicUrl(userId).data.publicUrl;
|
||||
return `${url}?v=${cacheBuster}`;
|
||||
}
|
||||
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
async function getAvatarFileName(
|
||||
userId: string,
|
||||
extension: string | undefined,
|
||||
) {
|
||||
const { nanoid } = await import('nanoid');
|
||||
const uniqueId = nanoid(16);
|
||||
|
||||
return `${userId}.${extension}?v=${uniqueId}`;
|
||||
function getAvatarFileName(userId: string) {
|
||||
return userId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user