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!!
0 -
Hi there,
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_id
of the asset, in conjunction with theoverwrite
parameter 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
* setpublic_id: <etag value>
overwrite: true
in 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 CloudinaryI hope this helps. I will link to some support articles we have that might provide additional information for you
https://support.cloudinary.com/hc/en-us/articles/208158309-How-can-I-completely-prevent-the-existence-of-image-duplications-on-my-Cloudinary-account-https://support.cloudinary.com/hc/en-us/articles/207441825-How-can-Cloudinary-help-me-to-avoid-duplications-on-my-account-
Hope this helps. Let us know if you need anything.0
Post is closed for comments.
Comments
2 comments