如何以本机脚本上传图像

时间:2018-09-10 09:44:56

标签: nativescript

我正在尝试通过{ rate = 5; quantity = 10; } 插件上传图片。

这是我的代码:

nativescript-background-http

当我尝试构建我的应用程序时,它将显示错误:

var session = bghttp.session("image-upload");
var request = {
  url: 'http://localhost:4200/',
  method: "POST",
  headers: {
    "Content-Type": "application/octet-stream",
    "File-Name": imageFile.name
  },
  description: "{ 'uploading': " + imageFile.name + " }"
};

var task = this.session.uploadFile(path, request);

错误所在的行正是这一行:

TypeError: Cannot set property 'NAMESPACE' of undefined

有什么主意吗?

1 个答案:

答案 0 :(得分:0)

我为您提供了解决方案。现在,使用后端服务器上的文件流方法可以很容易地使用本机脚本背景http上传图像。

https://www.ekpotoliberty.com/read/NativeScript-Image-Uploading-to-NodeJs-Api-+-Cloudinary-using-NativeScript-Background-HTTP/5dad52c76dc813685f8da26f

点击上面的链接将帮助您了解nativescript核心。

相关问题