0xtech0
Convex Community2y ago
21 replies
0xtech

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);
    }
  }, []);

I wanna get image url with stroage id after I uploaded image
Was this page helpful?