【问题标题】:Meteor How to upload files to cloudinary using lepozepo:cloudinary Firefox?Meteor 如何使用 lepozepo:cloudinary Firefox 将文件上传到 cloudinary?
【发布时间】:2017-06-17 03:55:45
【问题描述】:

我已经在 stackoverflow 上搜索过这个问题,但它们看起来都相似(实际上不是同一个问题),而有些问题却完全相反。

这是我的代码:

    Cloudinary.upload(file, {
        folder: "images",
        type: "private"
        }, (err, res) => {
            if(err) {
                console.log("Upload Error: ", err);
                alert("Sorry, there was an error uploading the image");
                return;
            }

            if (res) {
                console.log("Upload Result: ", res);
            }

        });

上面的代码适用于 safari 和 chrome,但在 Firefox 上失败。它快把我逼疯了!

Firefox 抛出错误提示:

File.lastModifiedDate is deprecated. Use File.lastModified instead.
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data[Learn More]  lepozepo_cloudinary.js:224:20
Cloudinary._upload_file/</<

不确定这里的问题是什么,感谢任何帮助。谢谢。

【问题讨论】:

    标签: javascript node.js firefox meteor cloudinary


    【解决方案1】:

    试试这个方法。在“上传”下的 Cloudinary 管理员“设置”中。选择有符号或无符号

    客户

    $.cloudinary.config({
        cloud_name: 'your-cloud-name',
        api_key: '1234xxxxxxxxxx'
    });
    
    let files = event.currentTarget.your_form_field_name.files;
    
     return Cloudinary.upload(files, {
    
     }, function(err, res) {
               if (err) {
                  console.error(err);
               } else {          
                  /** Do something with the response **/  
     });
    

    服务器

    //cloudinary
    Cloudinary.config({
        cloud_name: 'your-cloud-name',
        api_key: '1234xxxxxxxx',
        api_secret: '5678xxxxxxxx'
    });
    
    Cloudinary.rules.signature = function() {
        return this.userId;
    };
    

    请注意,如果您正在执行未签名的请求,您可能不需要签名

    【讨论】:

    • 嘿,感谢您的回复,我尝试了该方法,但仍然在 firefox 上遇到错误。你在使用 lepozepo:cloudinary 插件吗?
    • 哦,是的,看起来 Moziila 正在取消 API 的那部分。 Lepozepo 很可能必须更新他的软件包。
    • 修改包,或者等待lepozepo打补丁。我用这个包做了很多事情,所以我能感受到你的痛苦。
    • 这也可能有帮助,因为它直接来自 Cloudinary https://github.com/cloudinary/cloudinary_npm
    猜你喜欢
    • 1970-01-01
    • 2015-11-06
    • 2018-02-02
    • 2018-10-18
    • 2016-11-28
    • 2017-08-03
    • 2013-11-03
    • 2021-11-30
    • 2022-10-13
    相关资源
    最近更新 更多