Best way to avoid duplicated files.
Hi, I'm trying to find the best way to avoid duplicate files, this is what I tried.
1. set the parameters "public_id" and "overwrite: false" in my request, in the docs it mentions that the response is returned immediately, but I don't know why it doesn't work for me. the file takes the same time when is upload for the first time and response is not inmediatly like docs mention it, only response have a new param "existing: true"
2. I make a main request before uploading the file, I generate a url without 'version' and 'extension' and when I try to view the image in the browser url, I get a response with a 404 error, but when I upload the file for the first and then I make a request it works fine.
i appreciate any help thanks.
i found the way, I founded into the docs the manner to how bypass the cdn cache and force it to get the new assets
The version component is an optional part of Cloudinary delivery URLs that can be added to bypass the CDN cached version and force delivery of the newest asset.
Thanks for reaching out and I'm glad you found your answer.
I can share some more information that may help you or others in the future. The easiest way to avoid uploading duplicates would be to use the etag value as the
public_idof the asset, in conjunction with the
overwriteparameter set to false. Note: in order to proceed this way, you would need to calculate the etag value before your upload call, but every language has the functionality to do this.
So the process would be
* you generate the etag value on your machine
public_id: <etag value>
overwrite: truein your upload call
* if Cloudinary sees that this public id already exists, we just return the details of the existing resource
* if the public id does not exist, the file gets uploaded to Cloudinary
I hope this helps. I will link to some support articles we have that might provide additional information for you
Hope this helps. Let us know if you need anything.
Post is closed for comments.