fix: add default if boot data isn't present

This commit is contained in:
Safwan Samsudeen 2026-03-28 23:54:18 +05:30
parent 1049f5d6c2
commit b11ce887ba
2 changed files with 3 additions and 4 deletions

View file

@ -165,7 +165,7 @@ def upload_file():
file = files["file"]
filename = file.filename
if frappe.form_dict.chunk_index:
if frappe.form_dict.get("chunk_index") is not None:
current_chunk = int(frappe.form_dict.chunk_index)
total_chunks = int(frappe.form_dict.total_chunk_count)
offset = int(frappe.form_dict.chunk_byte_offset)

View file

@ -571,7 +571,7 @@ function return_as_dataurl() {
async function upload_file(file, i) {
currently_uploading.value = i;
const CHUNK_SIZE = frappe.boot.file_chunk_size;
const CHUNK_SIZE = frappe.boot.file_chunk_size || 25 * 1024 * 1024;
const use_chunks = file.file_obj && file.file_obj.size > CHUNK_SIZE;
const total_chunks = use_chunks ? Math.ceil(file.file_obj.size / CHUNK_SIZE) : 1;
@ -685,11 +685,10 @@ async function upload_file(file, i) {
xhr.setRequestHeader("X-Frappe-CSRF-Token", frappe.csrf_token);
let form_data = new FormData();
if (chunk_blob) {
form_data.append("file", chunk_blob, file.name);
}
form_data.append("is_private", +file.private);
form_data.append("folder", props.folder);
form_data.append("total_file_size", file.file_obj?.size ?? 0);