0

the docs here indicate an overwrite option:

overwrite (Boolean) - Whether to overwrite existing resources with the same public ID. When set to false, return immediately if a resource with the same public ID was found. Default: true.

When I set it to false, the files still upload all their data. This seems to be an error.

cld.uploader.upload(filePath, function(result) {
  if (result.error) {
    return done(result.error);
  }
  done();
}, {
  // Note these are the upload options.
  resourcetype: 'auto',
  publicid: publicId,
  overwrite: false,
});
Michael Cole
  • 15,473
  • 7
  • 79
  • 96

1 Answers1

0

When overwrite: false is used, Cloudinary checks whether there's an image existing in your account assigned with the same public ID as assigned in the upload options, if there isn't - The new image is uploaded. Otherwise, you got a response back, which looks like there was an upload performed, however the details you actually get from the response are of the already (old) uploaded image, not the new one. Also, an additional parameter is returned (existing), when it is returned as true this means that no upload has been made.

Itay Taragano
  • 1,901
  • 1
  • 11
  • 12
  • Hi Itay, ok, that's what the docs say, but it isn't working for me in the code above. Any suggestions? – Michael Cole Jul 02 '15 at 17:54
  • Isn't the `existing` parameter returned for you? If so, please contact Cloudinary's support, with an upload example's details and your cloud_name, and we'll be happy to take a deeper look in our logs. – Itay Taragano Jul 02 '15 at 22:38
  • Hi Itay, ok yes. I'm seeing `existing: true` in the output. The client is still transmitting the file though. I got the impression from the docs that the client would not re-transmit the data. Like a 409 response. http://stackoverflow.com/questions/14250991/is-it-acceptable-for-a-server-to-send-a-http-response-before-the-entire-request – Michael Cole Jul 02 '15 at 23:59
  • Hi Michael, the other options are to either do a HEAD request to the target resource and expect 404 before moving on, or having your own DB and keep track of the used public IDs on your end. – Itay Taragano Jul 03 '15 at 07:56