How to programmatically set Public ID with CldUploadWidget ? #301
Unanswered
ryanleeallred
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I've tried <CldUploadWidget
uploadPreset="<Upload Preset>"
options={{
publicId: username,
}}
onClose={(widget) => router.reload()}
>
...
</CldUploadWidget> But it appears that unsigned uploads don't allow for overwriting files with the same Public ID? I thought there was a setting within the upload preset to allow for files to be overwritten but I think I was mistaken? Do I need to be using signed uploads here? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to use Cloudinary to store user's profile pictures. I'm currently using the
CldUploadWidget
to do this with unsigned uploads.I would like to set the image's Public ID to be the user's username (unique) when the image is uploaded. That way, the image src will already be known for easy use with
CldImage
–and also, any future uploads from the same user will overwrite any image that they might have uploaded previously.I've dug through the CldUploadWidget Configuration Docs as well as the UploadWidget API Reference, but can't seem to figure out how to piece the different parts together.
Below is simplified code for my component. I'm hardcoding the username here to be "admin". That would normally be provided by a NextAuth user session.
Beta Was this translation helpful? Give feedback.
All reactions