Retaining the exact URL when a file is replaced with the same filename.
Hi,
If I upload a file through the browser then replace the file with a new file with the exact same filename, how can I retain the exact same URL?
Currently the URL changes
First upload: https://res.cloudinary.com/company/image/upload/v1637019407/folder/file.png
Second upload: https://res.cloudinary.com/company/image/upload/v1637019574/folder/file.png
This element changes: v1637019407 & v1637019574, how can I prevent the change or force URLs to remain the same?
Thank you
-
Official comment
Hi Matt,
Cloudinary automatically adds the version to URLs and this cannot be changed through configuration. You can safely strip off the version token from the URL to access the asset. For example:
https://res.cloudinary.com/demo/v1341324/sample.jpg is the same as https://res.cloudinary.com/demo/sample.jpg . Maybe you can try the following (assuming you are using our upload APIs to upload from the browser):
- Upload the new version of the asset
- Get the version assigned to it from the upload response. The version string is available in the response as"version": nnnnnnnnn,
See https://cloudinary.com/documentation/image_upload_api_reference#upload_response for a sample response.
- Programmatically Strip off the version in the url that is returned in the response and use it in your app."secure_url": "https://res.cloudinary.com/demo/image/upload/v1570979139/eneivicys42bq5f2jpn2.jpg",
Best
Akshay -
Hi Matt,
The version of an image in the Media Library is the timestamp of when your was last updated (e.g., v1366687335), and you may remove it from your delivery URL (see https://cloudinary.com/documentation/advanced_url_delivery_options#asset_versions). Cloudinary does not require the version component to be present in URLs, and it can be removed if you don't want to use that when building your URL.
For example:
https://res.cloudinary.com/company/image/upload/folder/file.png
Hope this helps.
0 -
Hi Eric,Thank you very much for the reply and link. Please could you or anyone confirm which settings need to be applied?
I have tried changing the ' Invalidate versioned URLs: Enable this if you use URLs with the version component, e.g. https://res.cloudinary.com/iporg/image/upload/v1637067637/sample.jpg ' and many other settings but the timestamp remains. Also, is there a way to reset all settings to default? I've tried many other them in attempt to get this working.
Thank you
Matt0 -
Hi Akshay,
Thank you very much for your reply. We're uploading through the web interface and currently we are not using the API. Images are therefore just called by their URL. I think from what you've described this means we cannot remove the version from the URLs
As per your example, when the URL is like this
https://res.cloudinary.com/demo/v1341324/sample.jpg
we want to call a URL like this
https://res.cloudinary.com/demo/sample.jpg
We wish to do this so we can replace the file e.g. sample.jpg with a new one by the same name. We want to do this by uploading through the web interface and overwriting or deleting the existing sample.jpg
Please confirm if this can be achieved without the API, else we will need to use another provider.
Thank you
Matt0 -
Hi Matt.
The inclusion of an asset's version number is entirely optional, and you can remove it from your delivery URL if you wish. It's worth bearing in mind though that because the updated asset will have the same URL, users of your site/application may need to refresh their local cache before they see any changes.
If your question is more around how you can get a versionless URL directly from the Media Library, we can make a change to your account that will update your Manage page to show separate Transform, Embed and Download buttons like so:
Upon clicking the embed code button, you'll be given the option to include or exclude the version number:
I've made a short video starring my cat that demonstrates everything I've said above, which I'll provide below. In this video I use an upload preset that is configured to keep the filename intact and overwrite any existing assets. I upload cat.jpg, get the image URL without a version number and then visit it in my browser. I then upload a different image called cat.jpg, open the same URL as before, and once I refresh, I see the updated image.
https://res.cloudinary.com/demo/video/upload/f_auto,q_auto/versioning.mp4Please let us know if you'd like us to make the change on your account so you can see a versionless URL within the Media Library, or if you'd prefer to just omit the version number manually.
Looking forward to hearing back from you.
0 -
Hi Danny,
Thank you very much for this detailed reply. The video was also very helpful. I may return to request the versionless URL.
Have a good day.
Matt0 -
Hi, i faced this issue too, but if i rip of the versioning, and try to access the url, i get the old asset instead of the new one
0 -
Hi,
As it is possible that the image without the version is still being cached in our CDN, you may need to perform an invalidation process through the Explicit API (i.e., with parameter invalidate=true) by using one of our SDKs or the Command-line interface (CLI). For example:
cld uploader explicit public_ID type=upload invalidate=true
In case it still does not purge the old image copy, please help to open a support ticket here (https://support.cloudinary.com/hc/en-us/requests/new) and provide the image URL so we investigate further on the case.
Thanks.
0
Post is closed for comments.
Comments
8 comments