【问题标题】:Cloudinary - Upload preset must be in whitelist for unsigned uploadsCloudinary - 上传预设必须在未签名上传的白名单中
【发布时间】:2018-04-03 05:35:32
【问题描述】:

我想将图像上传到 Cloudinary,使用 cordova 相机插件直接从 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
    });
}

【问题讨论】:

  • 你试过什么?错误代码来自什么?您是在使用某个应用程序还是只是通过浏览器上传?
  • 您能否检查所有必要的数据是否与 POST 请求一起正确发送?具体来说,upload_preset 似乎未正确发送,或未在您的 Cloudinary 帐户上正确配置(例如,列入白名单为未签名)
  • @ruchiYadav 更多详情见:cloudinary.com/blog/…

标签: ionic-framework cordova-plugins ngcordova cloudinary


【解决方案1】:

首先,您需要为您的 Cloudinary 帐户从 Upload Settings page. 启用未签名上传

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

【讨论】:

    猜你喜欢
    • 2019-01-09
    • 2020-11-07
    • 2023-04-01
    • 2019-01-23
    • 2014-09-27
    • 2018-08-01
    • 2016-12-19
    • 2019-12-14
    • 2017-05-10
    相关资源
    最近更新 更多