【问题标题】:Cordova Plugin File Transfer using HTTPS使用 HTTPS 的 Cordova 插件文件传输
【发布时间】:2018-02-17 14:43:57
【问题描述】:

这是我用来将图像传输到服务器的函数。它正在使用 http url,现在它在 https url 上给出了异常。我认为是因为cordova文件传输插件只支持http而不支持https。任何人都可以帮助我在 https 上进行这项工作,因为其他事情都依赖于它。

  public uploadImg(img, userId) {
/*if (credentials.email === null || credentials.password === null || credentials.name === null) {
  return Observable.throw("Please insert credentials");
} else {*/
// At this point store the credentials to your backend!
console.log(userId);
let options: FileUploadOptions = {
  fileKey: 'img',
  fileName: 'name.png',
  params: {action: 'upload_image', api_key: API_KEY, user_id: userId},
  httpMethod: 'post',
  mimeType: 'image/png'
}
console.log('upload function');
return new Promise(resolve => {
  this.fileTransfer.upload(img, encodeURI('https://exampledomain.com/api/api.php'), options)
    .then((data) => {
      console.log('uploaded image');
      console.log('APi response is' + data.response);

      let img = JSON.parse(data.response);
      console.log(img.status + ' ' + img.message);
      resolve(img)
      // success
    }, (err) => {
      console.log('image failed');
      reject(false)
      // error
    });
});
// } }

谢谢

【问题讨论】:

    标签: cordova ionic-framework cordova-plugins cordova-3 ngcordova


    【解决方案1】:

    This 主题帮助了我,我终于找到了解决方案。我正在回答这个问题,以便它可以帮助某人。您需要在选项中添加这个 chunkedMode=false 参数,然后它也可以与 https 一起使用。干杯!

    【讨论】:

    • 我设置了 chunkedMode=false 还是不行。我有一个正在生产的应用程序,这是一个可怕的问题。显然,文件上传在我的本地开发机器上工作正常。但是他们在 XCode 上使用 BoringSSL SSL_ERROR_SYSCALL 对 HTTPS 进行故障转移。 XCode 调试控制台中的错误说 库外部操作失败 所以我不确定这是插件问题,我的生产服务器上的问题还是什么。 SSL 证书。是正确的,映射很好。谁能澄清这个错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-11
    • 2021-01-09
    相关资源
    最近更新 更多