How to retrive UUID

Hey there this is my code I’m trying to get the UUID as seen in this part

const handleImageUpload = (fileInfo) => {
    if (fileInfo.uuid) {
      const imageUrl = `https://ucarecdn.com/${fileInfo.uuid}/-/preview/750x1000/`;
      setImageFiles((prev) => [...prev, { uuid: fileInfo.uuid, cdnUrl: imageUrl }]);
      toast.success("Image uploaded successfully");
    } else {
      toast.error("Image upload failed: No UUID received");
    }
  };

and so the URL formed after that with the uuid I wanted to send to my server but I’m unable to get the uuid my processes are failing I don’t know certainly why can I have some help here please?

@uploadcare/upload-client like ig I should be using this to retrieve the uuid but I just like the react Uploader so erm is there any other method?

Hi @Ranveer_Soni, I’ve looked at your code and noticed that you’re using the onChange event. In this case, the callback function receives a collection entry instead of a file entry, so it should be handled differently. Consider using the onFileUploadSuccess event instead. In this case, the callback will receive a file instance from which you can extract the file UUID and other file-related metadata.

<FileUploaderRegular
    pubkey="your_pub_key"
    sourceList="local, url, gphotos"
    classNameUploader="uc-dark"
    onFileUploadSuccess={handleImageUpload}
    accept="image/*"
/>

See Events for more information.

1 Like

Hello there, thanks for helping! that worked!!!