How can I update an already uploaded image?

When you upload a new image while specifying its public_id to be the same as an existing image, your Cloudinary account will be updated with the new image overriding the old one. However, if the original (older) image was already accessed, it might get cached in the CDN. Therefore if you access the exact same URL, you might be still getting a CDN cached version rather than the new updated one. For more information:
http://support.cloudinary.com/entries/23138893-I-ve-replaced-an-existing-image-with-a-new-one-but-my-website-stills-shows-the-old-one-Why-is-that-

We recommend to include the version component as part of the URL in order to bypass CDN cached version and to force the delivery of the newest image. Cloudinary returns the updated value of the version parameter as the part of every upload response. The url parameter is also returned which already includes the version component with the updated value.

For more information:
http://cloudinary.com/documentation/upload_images#image_versions

Alternatively, when using the API, you can set the invalidate parameter to true while uploading in order to invalidate the image through the CDN. Note that it might take up to an hour for the invalidation to fully propagate through the CDN, while the version component affects immediately. When uploading via the Media-Library the invalidation comes built-in in the request.

Also, note that in default Cloudinary invalidates URLs which do not include the version component. If you wish to invalidate "versioned" URLs, you should enable 'Invalidate versioned URLs' in your account's Upload settings page.

For more information:
http://cloudinary.com/documentation/upload_images#invalidating_cached_images_on_the_cdn

Another option you might want to consider is to add a unique suffix to the public ID with every re-upload.

Have more questions? Submit a request

Comments

  • Avatar
    Jerry Cornejo

    Because we don't want to have to change the image URL in the HTML code on our site every time we update an image, we are not using the version in the URL. As such, does this then mean that if we replace an image through the Media Library it will take up to an hour to update on our site? Is there no way to manually clear cache or at least reduce that wait time to a few minutes?

  • Avatar
    Nadav Ofir

    Hi Jerry,
    Usually this procedure shouldn't take more than a few minutes in order to be reflected to the majority of your users. However, since Akamai operates hundreds of thousands of servers around the world, our official commitment is for 1 hour invalidation.
    If you're experiencing specific high latency, don't hesitate to contact us with details via a support ticket.

  • Avatar
    Julbox Ltd

    Hello,
    What about tags and custom metadata? Are they getting overridden when uploading a new image with the same name?
    Thanks.

  • Avatar
    Nadav Ofir

    Hi Nimrod,
    Yes, this information is being overridden.

  • Avatar
    Julbox Ltd

    Thank you Nadav,
    Is there any way to keep the information but update the image?

  • Avatar
    Nadav Ofir

    At the moment you will have to provide the tags & metadata within the upload request payload. I added a feature request on your behalf to support keeping the existing resource information. We'll make sure to update here once it becomes supported.

  • Avatar
    James Gillmore

    When I provide the public_id for linked images, the media library panel doesn't seem to be able to replace it. It creates a new image with the upload icon, and that image actually never appears. In short, the system doesn't seem to be prepared for this case, and the web panel has the bug of not properly indicating as such.

    Please correct me if I'm wrong. I'd love to be able to replace linked images with manually uploaded ones.

  • Avatar
    Nadav Ofir

    Hi James,

    Uploaded and Fetched resources do not collide and therefore cannot override one each-other. Furthermore, "fetched" resources cannot be set a name (it's automatically named after the URL from which it was fetched) and "uploaded" cannot be named with sequential slashes (e.g. "http://")

    If you wish some further advising regarding your use-case, please feel free to open a support ticket and share some more information on your requirements.

  • Avatar
    James Gillmore

    i found the solution: auto-upload, which is virtually the same thing as fetched, excepted better. My suggestion is you guys remove the fetched solution--it's redundant and not as good and as a result complicates things for the user.

    I also think you guys should lead more with this feature, i.e. in your marketing materials. I figured out you guys were the best in town for this sorta thing (compared to myriad competitors like cloudimage.io), but your homepage and main marketing pages barely made it clear that one of your features was the same thing that many companies like cloudimage.io do as their main offering. I feel like that's the most enticing way to get images into your platform these days. Just my 2 cents.

  • Avatar
    Nadav Ofir

    Hi James,
    Your 2 cents are very much appreciated, thank you for the feedback!
    Here's the relevant documentation and some comparison made between the two different features: http://cloudinary.com/documentation/fetch_remote_images

    Feel free to contact us for further advising if necessary :)

  • Avatar
    marcospolanco

    My experience is that I am getting the same version number over and over again when uploading images with the same public_id as with code below:

    let params = CLDUploadRequestParams(params: ["public_id":myID as AnyObject])
    cloudinary.createUploader().upload(data: data, uploadPreset: "xxxx", params: params, completionHandler: {}

    This is in Swift on iOS; might you shed light on the cause?

    Thanks,

    Marcos

  • Avatar
    Nadav Ofir

    Hi Marcos,
    Make sure to use signed-upload protocol as the unsigned one doesn't allow overwriting existing images (for security reasons).
    See: https://support.cloudinary.com/hc/en-us/articles/208335975-How-safe-secure-is-it-to-use-unsigned-upload-from-web-browsers-or-mobile-clients-

  • Avatar
    Robert Lightfoot

    Using the Drag & Drop widget in the Cloudinary Media Library, how can I upload a new version of an image?
    e.g., I already have a file in Media Library, "sample.jpg"

    I want to replace that file with a newer version - so that only the version number (this part of the URL, /v9472981241) will change.

    But, when I drag & drop the new file (named that same as the already uploaded file, sample.jpg), the file gets uploaded and I end up with a file name like, "sample_vpbqfw.jpg"

    Is there a setting or something else that will allow me to be prompted when a 'duplicate' name exists, or that allows me to automatically update files is duplicate names exist?

    Thank you in advance for the assistance.

  • Avatar
    Maor Gariv

    Hi Robert,

    You can set the public_id of a drag&dropped image by clicking the "More upload options..." button and setting the public_id to the image you wish to change.

    Also, you can disable the random suffix characters when uploading - go to your account's Settings page and under Upload tab, choose Yes for "Use file name in Media Library"

Powered by Zendesk