最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

file - empty videos are uploading in bunny.net in javascript - Stack Overflow

programmeradmin0浏览0评论

I am uploading videos in bunny stream with JavaScript videos are uploading success fully but videos are empty and corrupted.

please help me it is very important to complete it thanks

here is my code:

const fileInput = document.getElementById('videoFile');
           
            let file = fileInput.files[0];
            console.log(file);
            video_name = file.name;
            let video;
            const toBase64 = file => new Promise((resolve, reject) => {
                const reader = new FileReader();
                reader.readAsDataURL(file);
                reader.onload = () => resolve(reader.result);
                reader.onerror = error => reject(error);
            });
async function Main() {
                video = await toBase64(file);
            }
            
           video =  Main();
        
            const options = {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                accept: 'application/json',
                AccessKey: 'e3214df7-7dba-4a74-b93649716004-454b-46c3'
            },
            body: JSON.stringify({ 'title': video_name }),
            
         };

        result = fetch('', options)
        .then(res => res.json())
        
        .then(res => {
               videoId = res.guid;
               console.log(videoId);
                const options = {
                method: 'PUT',
                headers: {
                    AccessKey: 'e3214df7-7dba-4a74-b93649716004-454b-46c3',
                    'Content-Type': 'application/octet-stream',
                },
                data: video,
                };

                fetch(`/${videoId}`, options)
                .then(res => res.json())
                .then(res => console.log(res))
                .catch(err => console.error(err));
            })
        .catch(err => console.error(err));

want solution of that its important

发布评论

评论列表(0)

  1. 暂无评论