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.