Uploading a video to a server with Ionic

我与影子孤独终老i 提交于 2021-02-05 07:55:09

问题


I am currently working on a Ionic application and I need to upload a video to my server with the Ionic Native File Transfer Plugin.

For this, I get my video from a GoPro. The downloading works. But I cant' upload the video. I checked, the application does not even connect to the website.

Upload code:

upload(){
   let options: FileUploadOptions = {
      fileKey: 'file',
      fileName: 'GOPR0061.MP4',
      headers: {}
   }

   var url = "http://mywebsite.com/api/video" ;

   this.fileTransfer.upload(this.video.toURL(), encodeURI(url), options, true)
    .then((data) => {
      console.log('It worked!' + data);
    }, (err) => {
      console.log('Try again' + err);
    })
 }

I did multiples console.log() and got this:

  • this.video.toURL() : file:///var/mobile/Containers/Data/Application/A724AA9F-A0F6-44B0-9L15-35SC0FD2S1F5/Library/NoCloud/GOPR0061.MP4
  • encodeURI(url) : http://mywebsite.com/api/video
  • options : [object Object]

We can see that the video file exists and the URL seems good. I have no .htaccess that could block the upload.

So if someone knows how to solve my problem, I would be really grateful!

来源:https://stackoverflow.com/questions/52762338/uploading-a-video-to-a-server-with-ionic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!