Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
upload video to bunny stream with axios

i need to upload video to bunny stream :bunny docs

i convert file to base64 as thy do here: upload file: BODY PARAMS

if you select js axios as LANGUAGE you'll see the data value set in base64

and this is my code:

function UploadVideo(e){
  const data = new FormData();
  let file = e.target.files[0];
  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);
  }
  
  Main();


  
  const c_options = {
    method: 'POST',
    url: 'https://video.bunnycdn.com/library/49034/videos',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/*+json',
      AccessKey: ''
    },
    data: '{"title":"test"}'
  };
  
  axios.request(c_options).then(function (c_response) {
    //upload start
    const u_options = {
      method: 'PUT',
      url: `https://video.bunnycdn.com/library/49034/videos/${c_response.data.guid}`,
      headers: {
        Accept: 'application/json',
        AccessKey: ''
      },
      data: video,
    };
    axios.request(u_options).then(function (u_response) {
      //post url to php
      console.log(u_response.data);
    }).catch(function (error) {
      console.error(error);
    });
    //upload end

    console.log(c_response.data);
  }).catch(function (error) {
    console.error(error);
  });
}

but it return status code 400 how can i do that?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!