0
votes

I am trying to replace an image on cloudinary using it's public_id. So, i made the signature using timestamp, public_id & overwrite. I had set up the overwrite value to 'true'. Below i have attached a screenshot of the parameter being passed. The image is successfully uploaded but with a different version tag but the original image is not replaced.

Curious thing is that the changed image successfully replaces the original image on first upload but does not work on any further uploads on that image. So, the uploads are successful but are uploaded with a different version tag.

http://cloudinary.com/documentation/upload_images#renaming_images I have used the overwrite option given in the above link to replace the original image.

I waited for quite a while (at least half an hour) thinking that changes might take time to reflect but it remained the same.

Any insight into what maybe wrong here ?

var newForm = new FormData();
newForm.append('timestamp',ts);
newForm.append('api_key', $rootScope.CLOUDINARY_CONFIG.api_key);
newForm.append('signature', signature);
newForm.append('public_id', scope.model.public_id);
newForm.append('overwrite', true);
newForm.append('file', canvasImage);

                    $http.post($rootScope.CLOUDINARY_CONFIG.upload_url, newForm, {
                      transformRequest: angular.identity,
                      file : canvasImage,
                      headers: {'X-Requested-With': 'XMLHttpRequest','Content-Type': undefined}
                    })
                    .success(function(data){
                      // success
                    })
                    .error(function(err){
                      // log error
                      console.log('fail');
                    });

enter image description here

1
Why is this tagged with [javascript]? Or better yet: Why is there no code in a [javascript] tagged question?Cerbrus
@Cerbrus - corrected. Thanks for pointing it outDhruv Balhara

1 Answers

1
votes

If you refer to being delivered with the same first uploaded image rather than the updated one, then it seems like you're getting a CDN cached version of the image. You should either include the version component in the URL (the correct version value is included in the upload response, alternatively, use the url returned by the upload call which already includes the version component), or you can set the invalidate parameter to true while uploading to invalidate the image. Note that it might take up to an hour for the invalidation to fully propagate through the CDN. Here's some more information