问题
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