【问题标题】:Unable to upload audio to the server无法将音频上传到服务器
【发布时间】:2017-01-15 08:23:35
【问题描述】:

我可以在本地上传音频。但是无法将音频上传到服务器。我的代码是:

module.exports.uploadAudio = function (req, res) {
    var form = new multiparty.Form();

    form.parse(req, function (err, fields, files) {
        console.log("Audio_Path=======>>>> " + JSON.stringify(files.file[0].path));

        cloudinary.uploader.upload(files.file[0].path, function (result) {
            console.log(result);
            obj.key2 = result.url;
            res.send({
                result: result,
                serverStatus: 200,
                response_message: "audio uploaded"
            });
        }, {
            resource_type: "auto"
        })
    })
}

【问题讨论】:

  • 欢迎来到 StackOverflow。查看 StackOverflow 帮助中心,了解如何提出一个好问题。 stackoverflow.com/help/how-to-ask。谢谢。
  • 你有什么错误吗?
  • 是的,找不到文件路径,这个问题只显示 MAC OS 。
  • 从“Cloudinary”的角度来看,代码看起来不错,关于“多方”方面不能说太多。您是否尝试验证传输的数据?

标签: javascript angularjs node.js multipartform-data cloudinary


【解决方案1】:

尝试使用“video”而不是“auto”作为属性“resource_type”的值:

cloudinary.uploader.upload(files.file[0].path, function (result) {
            console.log(result);
            obj.key2 = result.url;
            res.send({
                result: result,
                serverStatus: 200,
                response_message: "audio uploaded"
            });
        }, {
            resource_type: "video"
        })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-14
    • 2018-06-07
    • 1970-01-01
    • 2014-04-26
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    相关资源
    最近更新 更多