IONIC 3 FileTransfer错误上传图像浏览器

时间:2018-11-19 15:02:21

标签: ionic-framework ionic3 file-transfer

我正在按照https://ionicframework.com/docs/native/file-transfer/的说明,使用File Transfer插件文件在Ionic 3中实现上传功能。这是代码,

uploadFile() {
console.log("subiendo imagen")
let loader = this.loadingCtrl.create({
  content: "Uploading..."
})
loader.present()
const fileTransfer: FileTransferObject = this.transfer.create()

let options: FileUploadOptions = {
  fileKey: 'picture',
  fileName: 'category.jpg',
  chunkedMode: false,
  mimeType: "image/jpeg",
  headers: new HttpHeaders({
    'Content-Type': 'application/json',
    'Authorization': this.token
  })
}
options.params = {
  title: this.title,
  description: this.description,
}
fileTransfer.upload(this.imageURI, 'http://207.180.195.32:3000/categories/', options)
  .then((data) => {
    console.log(data + " Uploaded Successfully")
    loader.dismiss()
    this.presentToast("Image uploaded successfully")
    this.navCtrl.push(CategoriesPage)
  }, (err) => {
    console.log(err)
    loader.dismiss()
    this.presentToast(err)
  })
}

它抛出错误代码1。根据文档,它是FILE_NOT_FOUND_ERR:1,在chorme控制台中获得以下信息:

body: null
code: 1
exception: null
http_status: null
source:"iVBORw0KGgoAAAA..."
target: "my url"
<prototype>: Object { … }

在移动设备上,Android和ios可以完美运行,但在浏览器中却不能。

0 个答案:

没有答案