# Bitmovin api upload video

**URL:** <https://community.bitmovin.com/t/bitmovin-api-upload-video/3322>\
**Category:** Support\
**Created:** [October 2, 2024, 7:44am UTC](https://community.bitmovin.com/t/bitmovin-api-upload-video/3322 "2024-10-02T07:44:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool.bambyk](https://avatars.discourse-cdn.com/v4/letter/c/a4c791/32.png) [@cool.bambyk](https://community.bitmovin.com/u/cool.bambyk)\
**Post date:** [October 2, 2024, 7:44am UTC](https://community.bitmovin.com/t/bitmovin-api-upload-video/3322/1 "2024-10-02T07:44:47Z")

</div>

### Product

Streams

### Question

Is it possible for bitmovin api to get all audio tracks from video when uploading it to bitmovin?

---

<div class="post-metadata">

**Author:** ![cool.bambyk](https://avatars.discourse-cdn.com/v4/letter/c/a4c791/32.png) [@cool.bambyk](https://community.bitmovin.com/u/cool.bambyk)\
**Post date:** [October 2, 2024, 7:45am UTC](https://community.bitmovin.com/t/bitmovin-api-upload-video/3322/2 "2024-10-02T07:45:32Z")

</div>

My code is:

```auto
export async function uploadVideo(
  file: File,
  formData: UploadVideo,
  onProgress: (progress: number) => void,
  onSuccess: (videoId: string, videoUrl: string) => void
) {
  const { title, description } = formData;
  // 1. Generate URL for Direct File Upload
  const directFileInput =
    await bitmovinApi.encoding.inputs.directFileUpload.create(
      new DirectFileUploadInput()
    );

  if (!directFileInput.uploadUrl) {
    return;
  }

  // 2. Upload the file to the generated URL
  const request = new XMLHttpRequest();
  request.upload.addEventListener("progress", (event) => {
    if (event.lengthComputable) {
      const progress = (event.loaded / event.total) * 100;
      onProgress(progress);
    }
  });

  request.addEventListener("load", async () => {
    // Handle successful upload, parse the response, and call onSuccess with the videoId
    if (request.status >= 200 && request.status < 300) {
      // 3. Create a Stream with the uploaded video
      const streamRequest = new StreamsVideoCreateRequest({
        assetUrl: `https://api.bitmovin.com/v1/encoding/inputs/direct-file-upload/${directFileInput.id}`,
        title,
        description,
      });

      
      const stream = (await bitmovinApi.streams.video.create(
        streamRequest
      )) as Video;
      // 4. Call onSuccess callback with videoId

      onSuccess(stream.id, stream.assetUrl ? stream.assetUrl : "");
    } else {
      console.error("Upload failed:", request.responseText);
    }
  });

  request.open("PUT", directFileInput.uploadUrl);
  request.overrideMimeType(file.type);
  request.send(file);

```
