Cloudinary - Upload preset must be in whitelist fo

2019-09-19 13:57发布

I want to upload image, to Cloudinary, taken directly from camera in Ionic using cordova camera plugin. I am getting an error of code 1, having message "upload preset must be in whitelist for unsigned uploads." How to solve this error.Please help.

my edited js code is:

    $scope.cameraopen = function(){
   var options = {
         quality : 100,
         destinationType : Camera.DestinationType.FILE_URI,//FILE_URI
         sourceType : Camera.PictureSourceType.CAMERA,
         allowEdit : false,
         encodingType: Camera.EncodingType.JPEG,
         popoverOptions: CameraPopoverOptions,
         targetWidth: 500,
         targetHeight: 500,
         saveToPhotoAlbum: true
     };
$cordovaCamera.getPicture(options).then(function(imageData) {

var Uploadoptions = {
              upload_preset: cloudinary.config().upload_preset,
              tags: 'mytag',
              context: 'photo=photo', 
              file: imageData
            };

       var onUploadSuccess = function(data){
        console.log("success"+JSON.stringify(data));
       }
       var onUploadFail = function(e){
        console.log("error"+JSON.stringify(e));
       }

       var ft = new FileTransfer();
 ft.upload(imageData, "http://api.cloudinary.com/v1_1/" + cloudinary.config().cloud_name + "/upload", onUploadSuccess, onUploadFail, Uploadoptions, true); 
    }, function(err) {
      // error
    });
}

1条回答
贪生不怕死
2楼-- · 2019-09-19 14:24

First, you need to enable unsigned uploading for your Cloudinary account from the Upload Settings page.

Please refer the blog post on direct uploads from the browser and check. It can happen if some data necessary for the POST request is missing.

查看更多
登录 后发表回答