Skip to main content

Is it possible to upload directly to Cloudinary using pure JavaScript code?

Comments

14 comments

  • Adrian

    Hello Nadav!

    I'm getting the next error:

    {"error":{"message":"Unknown API key "}}

    I already tried inputting both the API key and the upload preset in the UI, am I supposed to put it somewhere in the code?

    Thanks in advance, this seems as easy as it gets and I really want to play around with it.

    1
  • Nadav Ofir

    Hi Adrian,

    If running via the shared jsFiddle, make sure to rerun the script once providing your cloud-name.

    0
  • Adrian

    Hello Nadav,

    I ran it locally and it worked, I didn't have to change a thing, I don't know what the problem was.

    Now, I have another question: I made a form with a file input, I need to do two very simple things but I can't find a direct instruction in the documentation.

    What I want my form to do is upload when the attachment is loaded and save the url property on another object I have. The submit button will push an object to my firebase and send you to a success page, but that part I have it covered.

    Here's a fiddle of my DOM:

    https://jsfiddle.net/e2bxx75c/

    0
  • Nadav Ofir

    Hi Adrian, the example that is shared above does exactly that.
    It uploads the image on submission and utilizes the response.

    Note that usually we recommend to store the public ID rather than the URL to allow more flexibility in adding transformations to your delivered images.

    0
  • jerome

    Hey, I'd like to make it work in a signed way but I keep getting this error:
    Response for preflight is invalid.

    In your snippet, I replaced this line:
    xhr.send(new FormData(formElement));
    by:
    var formData = new FormData();
    formData.append("timestamp", xxx);
    formData.append("signature", xxx);
    formData.append("api_key", xxx);
    xhr.send(formData);

    (I get the timestamp + signature + api_key from a previous ajax call to my server)

    1
  • Itay Taragano

    Please see the following example of how to upload using pure javascript:
    https://jsfiddle.net/tocker/fpoca4c8/

    While it uses unsigned uploads, the same principle can be implemented with signed uploads too by passing the relevant parameters.

    Please let us know if this helps?

    1
  • jerome

    I'm sorry but it doesn't work for me (it only works in unsigned mode).

    How do I pass the parameters? What's wrong with my code?

    1
  • Itay Taragano

    Thanks for your response, Jerome.
    Here's a working example, based on the previous example, but this time of signed uploads (demonstrated with PHP):
    https://gist.github.com/taragano/a000965b1514befbaa03a24e32efdfe5

    Please let me know if it works for you?

    0
  • Accion

    Is not possible send assigned files directly from my Browser?

    Need I use backend in PHP/JAva/NodeJS?

    0
  • Yakir Perlin

    Hi, 

    In order to perform signed upload from clinet side - you need to generate the signature on your backend, and then perform the upload with this signature.

    Please let me know if it works for you?

     
    0
  • Benjamin Aguilar

    Hi, I was trying to create the call in a different way with jquery

    var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.cloudinary.com/v1_1/<cloud name>/image/upload",
    "method": "POST",data:{"upload_preset":"xcc2qerf", "file":"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAIAAACyr5FlAAAPPklEQVR4AezSAQ0AAAwCILPYP+QTfDMAZCDlQQpyIAdyIAdyIAdyIAdyIAfIgRzIgRzIgRzIgRzIgRwgB2sOkOPYO/Pntq4qjv8v59z3nvandbFky9buRYnjJYntOPEaO83eNV3SZmkD0AIDU4AClMIALRRKoS3QArSsBUqhBQoQtvKncEaS7zxSRb5+fkrfk893vj8wDMNE1md07z2rQCCFUpnIwCAiAovhkLo8gwCg+fy1jXPFYxvRoSIKASyGYzgG/3pYxAJAys/M1zbPk0vLJ+LFqtB02MtiOK7M4n+viTsaCABmbojIkK6snUpWxzXDB6y9Cccv7xEExyvnBQCg0AgIwsLq6vqZ9NikEQwBa0/BMZoGIqPlkTiQso0pAqKDN85l9834wibDsVf02DxKOK4dQgAIJlKEQhfnp+YCsQTD0edChDcfEBKON+4XCECiB0t3PshDhxb90RjD0beaziMxYTX9NwBAl1AJQTc+Di4yHH2rTx27EY4nlhEAjFBYBY7qxjndH2A4+lC6gD8/JG6A42+XhV8HUmFuSYWPRKnGcPShjoygFQvpjSoCQKxQUoFjZHGd4ehDfXG1MxzfOokAoBlGdeOsCh/9di1lOAI6/P2K6AjHu4+IVAhIuanDKnBkxicZjr7SehWJg5v5vkkEgHAmpwJHefUkIDIc/aNnNrvB8epdAkiIldWTKnyEMwMMR5/I9FMaliDo5loKSJRSUYEjd+AQw9EnOjuO3ckgf2QeASAQjSsFPI6fFbrBcPSDvntGbAvHWxeFJoA0srimwgfVBzEcnlc6BPQe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x3ZCpJ8KQoRaHQER+l2aYdBUscr6aeKDJkgxHDeKJQwjXW8kSnWGg3UTITIcLO6yh/+1SwckAAAAAIL+v25HoBtEDuRADuQAOZADOZADOZADOZADOZAD5EAO5EAO5EAO5GAmzip4Pxpq2U8AAAAASUVORK5CYII="},
    "headers": {
    "cache-control": "no-cache",
    }
    }

    $.ajax(settings).done(function (response) {
    console.log(response);
    });

    This is returning {"error":{"message":"Unsupported source URL: data:image/png;base64, .... and if I do instead 

     

    var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.cloudinary.com/v1_1/<cloud name>/image/upload",
    "method": "POST",data:{"upload_preset":"xcc2qerf", "file":"data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAIAAACyr5FlAAAPPklEQVR4AezSAQ0AAAwCILPYP+QTfDMAZCDlQQpyIAdyIAdyIAdyIAdyIAfIgRzIgRzIgRzIgRzIgRwgB2sOkOPYO/Pntq4qjv8v59z3nvandbFky9buRYnjJYntOPEaO83eNV3SZmkD0AIDU4AClMIALRRKoS3QArSsBUqhBQoQtvKncEaS7zxSRb5+fkrfk893vj8wDMNE1md07z2rQCCFUpnIwCAiAovhkLo8gwCg+fy1jXPFYxvRoSIKASyGYzgG/3pYxAJAys/M1zbPk0vLJ+LFqtB02MtiOK7M4n+viTsaCABmbojIkK6snUpWxzXDB6y9Cccv7xEExyvnBQCg0AgIwsLq6vqZ9NikEQwBa0/BMZoGIqPlkTiQso0pAqKDN85l9834wibDsVf02DxKOK4dQgAIJlKEQhfnp+YCsQTD0edChDcfEBKON+4XCECiB0t3PshDhxb90RjD0beaziMxYTX9NwBAl1AJQTc+Di4yHH2rTx27EY4nlhEAjFBYBY7qxjndH2A4+lC6gD8/JG6A42+XhV8HUmFuSYWPRKnGcPShjoygFQvpjSoCQKxQUoFjZHGd4ehDfXG1MxzfOokAoBlGdeOsCh/9di1lOAI6/P2K6AjHu4+IVAhIuanDKnBkxicZjr7SehWJg5v5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MNhEaJERDGzaphx8KxQaPGRys1Gl1bWTiMKhuMGQgiRBJ0U2z9WDQO8L6Fp8WKVmiI7DTrOMhyd5YsnOyJijsnHav8INS1RHqWUvRWOzMQBhqOLkDLs1jwLtS3JzGr/Seh6sjImA6nl5RMMx3ZCpJ8KQoRaHQER+l2aYdBUscr6aeKDJkgxHDeKJQwjXW8kSnWGg3UTITIcLO6yh/+1SwckAAAAAIL+v25HoBtEDuRADuQAOZADOZADOZADOZADOZAD5EAO5EAO5EAO5GAmzip4Pxpq2U8AAAAASUVORK5CYII%3D"},
    "headers": {
    "cache-control": "no-cache",
    }
    }

    $.ajax(settings).done(function (response) {
    console.log(response);
    });

     

    I get {"error":{"message":"public_id (anonymous/data_3Aimage_2Fpng_3Bbase64_2C... I do not understand what I am doing wrong

     

    0
  • Yakir Perlin

    Hi ,

     

    Could you please try this code:

    var form = new FormData();

    form.append("file", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...........");
    form.append("upload_preset", "xcc2qerf");

    var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.cloudinary.com/v1_1/<cloud_name>/image/upload",
    "method": "POST",
    "headers": {
    "Cache-Control": "no-cache",
    },
    "processData": false,
    "contentType": false,
    "mimeType": "multipart/form-data",
    "data": form
    }

    $.ajax(settings).done(function (response) {
    console.log(response);
    });

     

    Please let me know if it works for you.

     

    Thanks,

    Yakir

    0
  • Troy

    Goals.  All accomplished in a progressive web app, not native app. 
    - User takes picture with device camera which is stored locally. 
    - User initiates sending image to Cloudinary via javascript 
    - Using your eager_notification_url, we are notified at our server after transformation is complete so we can do further processing as necessary.  Able include tags and context parameters.

    Is this possible with javascript? It seemed the eager_notification_url was not an option with signed or unsigned javascript implementations. I would really like this positive experience for the user and separate notification at our server.

    Examples truly appreciated in your response.

    0
  • Roee Ben Ari

    Hi Troy, 

    You can set the eager notification URL via an upload preset, under 'Eager Notification URL'.

    0

Please sign in to leave a comment.