Cloudinary - 上传预设必须为白名单,以便进行未签名的上传

时间:2016-01-28 10:19:30

标签: ionic-framework cordova-plugins ngcordova cloudinary

我想使用cordova相机插件将图像上传到Cloudinary,直接从Ionic中的相机拍摄。我收到代码1的错误,有消息“上传预设必须在白名单中才能进行未签名的上传”。 如何解决这个错误。请帮助。

我编辑的js代码是:

    $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 个答案:

答案 0 :(得分:1)

首先,您需要从Upload Settings page.

为您的Cloudinary帐户启用未签名的上传

Please refer the blog post on direct uploads from the browser and check。如果缺少POST请求所需的某些数据,可能会发生这种情况。