How can I upload videos from my library to Firebase storage?


#1

Hello everybody, I want to upload videos from my photolibrary to Firebase storage but i don’t know how is possible to do.
I have had success uploading images from my library with Native camera plugin
However, I have tried upload it with the same way with this options:

CameraOptions = {

        sourceType         : this.camera.PictureSourceType.PHOTOLIBRARY,
        destinationType    : this.camera.DestinationType.FILE_URI,
        mediaType: this.camera.MediaType.VIDEO
    };

And get the path with getPicture() method

this.camera.getPicture(this.videoOptions).then((videoData) => {
     let videoPath = 'data:video/mp4;base64,' + videoData;
     resolve(videoPath);
 });

and upload with this method:

uploadVideo(videoString:string): Promise<firebase.storage.UploadTaskSnapshot>{
     
       return new Promise((resolve, reject) => {

           let videoName: string = "video-"+ new Date().getTime() + ".mp4";
           let storageRef: firebase.storage.Reference = null;
           let parseUpload: firebase.storage.UploadTask;

           let url:string = "videoFolder/";
           storageRef =  firebase.storage().ref(url+videoName);
           parseUpload = storageRef.putString(imageString, "data_url");

           parseUpload.then(() => {
               resolve(parseUpload.snapshot);
           }).catch(error => console.error(error));
       });

    }

What am I doing bad?? if with that plugin is impossible to do that, how can upload my video??
Thank you so much guys.


#2

Someone can help me please? I need a solution:cry::cry:


#3

@CSantos8 did you find any solution? :’(