Hello
I have a custom HTML page where I created a registration form that includes a file input for users to upload their CVs. I am using JavaScript to upload the files to a REST API (/api/method/upload_file) and save them as a file doctype.
Here’s the issue I’m facing: a PDF file of the same size (8 MB) can be uploaded very quickly (in about 1 second), whereas a JPG file of the same size (8 MB) takes significantly longer (around 21 seconds) to upload.
What could be the reason for this, and how can I resolve it?
async function File_Upload(file) {
let file_data = new FormData();
if (upload_file) {
file_data.append('file', upload_file);
file_data.append('doctype', 'mydoctype');
file_data.append('docname', 'aaaaa');
file_data.append('is_private', 1);
}
if (upload_file) {
let token = await GetToken();
if (upload_file.size > 10000000) {
frappe.throw("File is very big");
} else {
let file_res = await fetch('/api/method/upload_file', {
headers: {
'Authorization': `Token ${token.message}`
},
method: 'POST',
body: file_data
});
if (!file_res.ok) {
frappe.throw("some error message");
}
let data = await file_res.json();
}
}
return {msg: 'error ', error_detail: 'error detail...'}
}