fix: add default if boot data isn't present
This commit is contained in:
parent
1049f5d6c2
commit
b11ce887ba
2 changed files with 3 additions and 4 deletions
|
|
@ -165,7 +165,7 @@ def upload_file():
|
||||||
file = files["file"]
|
file = files["file"]
|
||||||
filename = file.filename
|
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)
|
current_chunk = int(frappe.form_dict.chunk_index)
|
||||||
total_chunks = int(frappe.form_dict.total_chunk_count)
|
total_chunks = int(frappe.form_dict.total_chunk_count)
|
||||||
offset = int(frappe.form_dict.chunk_byte_offset)
|
offset = int(frappe.form_dict.chunk_byte_offset)
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ function return_as_dataurl() {
|
||||||
async function upload_file(file, i) {
|
async function upload_file(file, i) {
|
||||||
currently_uploading.value = 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 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;
|
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);
|
xhr.setRequestHeader("X-Frappe-CSRF-Token", frappe.csrf_token);
|
||||||
|
|
||||||
let form_data = new FormData();
|
let form_data = new FormData();
|
||||||
|
|
||||||
if (chunk_blob) {
|
if (chunk_blob) {
|
||||||
form_data.append("file", chunk_blob, file.name);
|
form_data.append("file", chunk_blob, file.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
form_data.append("is_private", +file.private);
|
form_data.append("is_private", +file.private);
|
||||||
form_data.append("folder", props.folder);
|
form_data.append("folder", props.folder);
|
||||||
form_data.append("total_file_size", file.file_obj?.size ?? 0);
|
form_data.append("total_file_size", file.file_obj?.size ?? 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue