对于未签名的上传,Cloudinary - 上传预设必须为白名单 [英] Cloudinary - Upload preset must be in whitelist for unsigned uploads

查看:577
本文介绍了对于未签名的上传,Cloudinary - 上传预设必须为白名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我编辑的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
    });
}


推荐答案

首先,你需要启用来自上传设置页面的Cloudinary帐户的未签名上传。

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

请参阅有关从浏览器直接上传的博客文章并查看 。如果缺少POST请求所需的某些数据,可能会发生这种情况。

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.

这篇关于对于未签名的上传,Cloudinary - 上传预设必须为白名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆