简体   繁体   中英

uploading video to firebase storage in react native

can someone please tell me how to upload video to firebase storage from image picker in react native. I have the code for uploading the images but not working for video so if there any example I will be appreciated. thank in advance.

const uploadUri = your_Video_Link;
        let filename = uploadUri.substring(uploadUri.lastIndexOf('/') + 1);
        
        const blob = await new Promise((resolve, reject) =>{
            const xhr = new XMLHttpRequest();
            xhr.onload = function(){
                resolve(xhr.response);
            };
            xhr.onerror = function(){
                reject(new TypeError("Network request failed"));
            };
            xhr.responseType = "blob";
            xhr.open("GET", uploadUri, true);
            xhr.send(null);
        });

        try {
            await storage().ref('Posts/' + filename).put(blob)
        } catch (e) {
            console.log("Upload video error = ", e)
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM