I can't figure out how to overwrite
an image when performing unsigned uploads
with Cloudinary.
All my users have access to their _id
from my Database, and they use that idea to perform a first upload, which works fine :
$('.upload_form').append($.cloudinary.unsigned_upload_tag("my_preset",
{
cloud_name: "...",
public_id: "...." //There goes each of my user's unique id
overwrite: true //That' where I hope to overwrite previous imgs
// in case user does another submission.
}
The general idea is to serve all images only based on user's id
so I don't have to store the url in my database. The main problem with the previous code, is that it throw the following POST error:
POST 400 Bad Request, Preview {msg:"Overwrite When using unsigned upload only upload_preset,callback,public_id,folder,tags,context,face_coordinates,custom_coordinates upload parameters are allowed"}
I don't understand because the only extra parameters, based on the error msg, is cloud_name
. And I can't remove that, otherwise I get another logical error : invalid request
I've looked through the doc, it's not very clear yet. Has anyone faced this probleme before ? Overwriting image using unsigned upload ?
Thanks
The overwrite
parameter isn't supported for unsigned uploads. Since unsigned uploads has some vulnerability security-wise, if overwriting was enabled, anyone could take your code and upload new images while overriding existing resources of your account, not only their own pictures, but others too.
If you need to allow overwriting images, you might want to consider switching to signed uploads.