上传功能版本 - 请求没有附加文件

问题描述

我有一个电子应用程序,每当我尝试使用此请求生成函数资源时:

async function createFunctionResource(serviceUid,functionUid,client){
    let collect_file = await templates.getCollect()

    let url = `https://serverless-upload.twilio.com/v1/Services/${serviceUid}/Functions/${functionUid}/Versions`

    let form = new FD();
    console.log(collect_file)
    form.append("Path","collect");
    form.append("Visibility","public");
    form.append("Content",collect_file,"collect.js");
    form.append("contentType","application/javascript");
    
    await axios.post(url,form,{
    headers: {
        Authorization: 'Basic ' + Buffer.from(`${client.accountSid}:${client.password}`).toString('base64'),...form.getHeaders(),},})  
}

我收到一个错误

C:\xxx\electron\node_modules\axios\lib\adapters\xhr.js:177 POST https://serverless-upload.twilio.com/v1/Services/ZSfd64dd7e41d5cea867e52f609013beba/Functions/ZH255e26a106ab1373aae410e65e05f8a9/Versions 400 (Bad Request)

其中返回的有效负载错误 400:

{"message":"No file attached to request","code":70002,"user_error":true,"http_status_code":400,"params":{}}

这在节点环境中完全正常,因此当我尝试将它与电子一起使用时,我会预加载包,以便我可以使用节点 API,但在发送 POST 请求时似乎出现问题。

任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)