0xtech
0xtech
CCConvex Community
Created by 0xtech on 4/9/2024 in #support-community
How to get image url after uploaded image ?
const handleAvatarUpload = useCallback(async (file: File) => {
try {
setUploadLoading(true);
const postUrl = await generateUploadUrl();
// Step 2: POST the file to the URL
const result = await fetch(postUrl, {
method: "POST",
headers: { "Content-Type": file!.type },
body: file,
});

const { storageId } = await result.json();
} catch (error) {
toast("Something went wrong", {
description: "Our support team has been notified",
});
console.error("Failed to update user profile", error);
}
}, []);
const handleAvatarUpload = useCallback(async (file: File) => {
try {
setUploadLoading(true);
const postUrl = await generateUploadUrl();
// Step 2: POST the file to the URL
const result = await fetch(postUrl, {
method: "POST",
headers: { "Content-Type": file!.type },
body: file,
});

const { storageId } = await result.json();
} catch (error) {
toast("Something went wrong", {
description: "Our support team has been notified",
});
console.error("Failed to update user profile", error);
}
}, []);
I wanna get image url with stroage id after I uploaded image
22 replies