cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

corrupted file will save on Dropbox`s Temporary link

corrupted file will save on Dropbox`s Temporary link

Esikhoob
Helpful | Level 5

Hi

In our website, there is an option to uploads files to a Dropbox account. I have used Dropbox`s Temporary link for this purpose. I have implemented a solution which create the Temporary link using C# Dropbox SDK , and then upload file using jQuery ajax post formdata.

The problem is that all video files (.mp4, .avi) get corrupted after this upload. Other files type get upload successfully.

After creating a Temporary link (for example: https://content.dropboxapi.com/apitul/1/eE8ccUfewDC6NQ) , I use this code to upload:

 

 

 

 

 

<form action="https://content.dropboxapi.com/apitul/1/eE8ccUfewDC6NQ" method="post" enctype="multipart/form-data">
            <input name="fileDropbox" type="file" class="form-control input-lg" readonly="true" onclick="return false;">
</form>

 

 

 

 

 

 

The above form will pass to following function via funtion`s "fileForm" parameter

 

 

 

 

 

function uploadFileToDropbox(fileForm, el) {
    const postData = new FormData(fileForm);
    $.ajax({
        url: $(fileForm).attr("action"), // Dropbox
        type: 'post',
        data: postData,
        crossDomain: true,
        dataType: 'json',
        success: function (res) {
            fileUploadRemain -= 1;
            if (fileUploadRemain === 0) // آیا همه فایلها آپلود شدند
                uploadLinkPreFile(el);
        },
        error: function (error) {
            let errorMess;
            if (error.error === undefined)
                errorMess = error;
            else if (error.error.error_summary === undefined) {
                errorMess = error.responseText; // مثلا: خطای پر شدن حساب دراپباکس
            }else  {
                errorMess = error.error.error_summary;
                console.log(error.error);
            }
            sendErrors.append("<div class='alert alert-danger'>خطا در " + errorMess + " :Dropbox</div>");
            el.modal("hide"); // خطا را خوب اون پشت نوشتی، باید اینو ببندم یا نه؟!؟
            App.unblockUI(el);
            App.scrollTo(sendErrors);
        },
        cache: false,
        contentType: "application/octet-stream",
        processData: false
    });
}

 

 

 

 

 

 

 The upload will finish with no error, but after downloading, the file is corrupted.

This is a sample of corrupted video file:

Trados_Learning.mp4 (dropbox.com)

please help me to resolve this problem. 

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20

@Esikhoob wrote:

...

 The upload will finish with no error, but after downloading, the file is corrupted.

This is a sample of corrupted video file:

Trados_Learning.mp4 (dropbox.com)

please help me to resolve this problem. 


Hi @Esikhoob,

The file not only has finished without error but is definitely not corrupted! It's another story that you cannot play this file in regular way, because of some upload mistake you have (error that's not reported, cosa Dropbox server cannot know about it). Just as an example see a screenshot of your video posted (on second 3 out of 23:34):

Screenshot_20240314_163136.png

🤔 Is that you or whoever you took a shot of? 😁

Dropbox API (and all links produced) gives and expect raw data, not something else! Something you have ignored!!! How you got your data (movie) passed? 🧐


@Esikhoob wrote:

...

 

<form action="https://content.dropboxapi.com/apitul/1/eE8ccUfewDC6NQ" method="post" enctype="multipart/form-data">
            <input name="fileDropbox" type="file" class="form-control input-lg" readonly="true" onclick="return false;">
</form>

 

...


That's it. You still receive the same video, but "packed" in multipart form data. And since that's what you have forwarded, exactly the same you receive. Of course, most video players cannot distinguish packed video in such a way. Again, the keyword is raw data!!! Don't ignore it anymore and all will work. 😉

Hope this helps.

View solution in original post

3 Replies 3

Здравко
Legendary | Level 20

@Esikhoob wrote:

...

 The upload will finish with no error, but after downloading, the file is corrupted.

This is a sample of corrupted video file:

Trados_Learning.mp4 (dropbox.com)

please help me to resolve this problem. 


Hi @Esikhoob,

The file not only has finished without error but is definitely not corrupted! It's another story that you cannot play this file in regular way, because of some upload mistake you have (error that's not reported, cosa Dropbox server cannot know about it). Just as an example see a screenshot of your video posted (on second 3 out of 23:34):

Screenshot_20240314_163136.png

🤔 Is that you or whoever you took a shot of? 😁

Dropbox API (and all links produced) gives and expect raw data, not something else! Something you have ignored!!! How you got your data (movie) passed? 🧐


@Esikhoob wrote:

...

 

<form action="https://content.dropboxapi.com/apitul/1/eE8ccUfewDC6NQ" method="post" enctype="multipart/form-data">
            <input name="fileDropbox" type="file" class="form-control input-lg" readonly="true" onclick="return false;">
</form>

 

...


That's it. You still receive the same video, but "packed" in multipart form data. And since that's what you have forwarded, exactly the same you receive. Of course, most video players cannot distinguish packed video in such a way. Again, the keyword is raw data!!! Don't ignore it anymore and all will work. 😉

Hope this helps.

Greg-DB
Dropbox Staff

@Esikhoob Здравко is correct; it looks like you're uploading the video as form data, but you need to send the original raw video data, not modified with any formatting or additional encoding. I confirmed that the file you shared starts with "------WebKitFormBoundaryaCK6EdHRBgQMkUuo..Content-Disposition: form-data;". You'll need to update your implement to upload the raw video data only.

Esikhoob
Helpful | Level 5

Yes That is me.

thankyou

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Esikhoob Helpful | Level 5
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?