【问题标题】:Cannot upload Cloudinary image Node.js无法上传 Cloudinary 图像 Node.js
【发布时间】:2017-12-02 15:40:46
【问题描述】:

我正在尝试通过 url 将图像上传到 cloudinary。我试过以下代码:

        var new_url = $.cloudinary.url(currentPostId+"_front_image.jpg");
        console.log(new_url);
        console.log("check_first");
        Cloudinary.upload(new_url, {public_id: postProperties._id+"_front_image"}, function(err, res) {
          console.log(err);
          console.log("Upload Result: " + res);
          console.log("check_second");
        });
        console.log("check_third");

我确定 new_url 是有效的,因为我可以打开它并查看图像。我做了两个console.log,但我发现我可以得到“check_first”和“check_third”,但不能得到“check_second”。似乎 Cloudinary.upload 功能不起作用(我也尝试过 cloudinary.uploader.upload() 但仍然失败)并且我的控制台上没有错误消息.我不知道发生了什么。如果有人能提供帮助,我真的很感激。

【问题讨论】:

    标签: url meteor file-upload upload cloudinary


    【解决方案1】:

    您似乎正在向上传者发送 Cloudinary URL(即http://res.cloudinary.com/<cloud_name>/image/upload/<image_name>。上传将无法进行,因为没有这样的文件。

    尝试将图像本身传递给上传者(从本地路径或远程位置,任何httphttps URL)。

    那么,上传调用应该是 -

    cld.uploader.upload('<image>',function(res){console.log(res);},{public_id:"<public_id>"})
    

    有关 Cloudinary 数据上传选项的更多信息 - http://cloudinary.com/documentation/upload_images#data_upload_options

    【讨论】:

      猜你喜欢
      • 2014-01-12
      • 2016-04-28
      • 2021-09-03
      • 2015-04-15
      • 2015-12-19
      • 2017-02-23
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      相关资源
      最近更新 更多