How do I pass media file to Strapi media fields?

Hi guys. I’m struggling with passing media file through Strapi API. I don’t know what type of data does this field want. Please help me.
Here is my code :

                        <div class="row gy-4 loading">
                            <div class="col-md-12">
                                <label for="nguoiHuongDan" class="required">Thông tin người hướng dẫn / hỗ trợ trực tiếp</label>
                                <textarea rows="10" type="text" class="form-control" id="nguoiHuongDan" name="nguoiHuongDan" required=""></textarea>
                            </div>

                            <div class="col-md-12">
                                <label for="baiGiang" class="required">Tải lên bài giảng</label>
                                <div id="drop-area" class="file-upload">
                                    <input type="file" id="baiGiang" name="baiGiang" accept=".zip,.rar,.7zip" onchange="updateFileName(this.files)">
                                    <span class="file-upload-label">Click hoặc kéo thả file SCORM (.zip) vào đây</span>
                                    <div id="file-name"></div>
                                </div>
                            </div>
                        </div>
   // a convert file to base64 function

  //upload file
  const handleUploadFile = async (event) => {
    event.preventDefault();

    const form = event.target;
    const formData = new FormData(form);

    const file = formData.get('baiGiang');
    let base64File = '';

    if (file) {
        base64File = await convertFileToBase64(file);
    }

    const dataObject = {
        nguoiHuongDan: formData.get('nguoiHuongDan'),
        baiGiang: base64File
    };


    try {
        const response = await fetch(ipAddr, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                data: dataObject
            }),
        });

This topic has been created from a Discord post (1283856119365632143) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Hey Do you have a git repository to have a look at to help you ?

here

Here is a pretty straight forward example you can take some inspiration from How to upload an image to strapi - DEV Community