How to integrate Cloudinary with appery.io apps?

In order to upload files to Cloudinary, a signature of the upload parameters needs to computed and supplied as in the upload request. This means you should probably either pre-sign the parameters with using your accounts credentials and with the aid of one of our client libraries. Or, in case these parameters change from one image upload to the next, have a server components that computes the signature upon request.

Alternatively, you can use unsigned uploads. For more information:
http://cloudinary.com/blog/direct_upload_made_easy_from_browser_or_mobile_app_to_the_cloud

Below is a code sample that uses unsigned upload:

// Let's assume the imageURI was received following a photo taken or a media browse selection
uploadPhoto: function(imageURI) {
    var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
    options.mimeType="image/jpeg";

    // these are the upload parameters - note that these are actually almost empty since we're not supplying any special upload
    // upload parameters. So the signature is really the result of signing your api_secret
    var params = {upload_preset: "{THE PRE-DEFINED UNSIGNED PRESET}"};

    options.params = params;

    var ft = new FileTransfer();
    ft.upload(imageURI, encodeURI("https://api.cloudinary.com/v1_1/<YOUR_CLOUD_NAME>/image/upload"), this.win, this.fail, options);
},

win: function(r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
},

fail: function(error) {
    alert("An error has occurred: Code = " + error.code);
    console.log("upload error source " + error.source);
    console.log("upload error target " + error.target);
}
Have more questions? Submit a request

Comments

  • Avatar
    Georgi Georgiev

    With this I get the following error: [FileTransferError]: body: "{"error":{"message":"Missing required parameter - file"}}"

Powered by Zendesk