Hey everyone! I am having trouble uploading videos to my AWS S3 directly from my Typescript. I can upload text files perfectly fine so I am under the impression that my credentials and how I am uploading are fine, but i could be wrong. I am currently using the media-capture plugin to record a video through the camera and automatically upload it to my S3 bucket using the Javascript SDK, but my File.readAsArrayBuffer is giving me a “code”:5,“message”:“ENCODING_ERR” Any help with this would be greatly appreciated! I’m new to Ionic 2 so please don’t spare details.
recordClick(){
MediaCapture.captureVideo().then((data: MediaFile[]) => {
console.log("---------Data:---------------");
console.log(data);
console.log("---------Name:--------------");
console.log(data[0].name);
console.log("---------Filepath:-----------");
console.log(data[0].fullPath);
File.readAsArrayBuffer(data[0].fullPath, data[0].name).then(
(success) => {
console.log("----Successfully read the file!---");
this.uploadToS3(success); },
(err) => {
console.log("----File Reading Failed!----");
console.log(err);
});
},
(err) => {console.log(err)}
);
}
uploadToS3(fileIn, nameIn){
// let video = new Blob([file], {type: "video/quicktime"});
var params = {Bucket: 'myBucket', Key: nameIn, Body: fileIn};
this.s3.upload(params, function(err, data) {
console.log("---S3 Upload----");
console.log(err, data);
});
}
Note: The above code is just the relevant part of my ts file, I have all the appropriate imports and all the appropriate plugins have been installed.
Thank you!