fix: allow setting chunk size from site settings

This commit is contained in:
Safwan Samsudeen 2026-03-10 12:48:26 +05:30
parent 05901488d5
commit 8fe9996e30
3 changed files with 7 additions and 2 deletions

View file

@ -151,9 +151,10 @@ def get_letter_heads():
def load_conf_settings(bootinfo):
from frappe.core.api.file import get_max_file_size
from frappe.core.api.file import get_file_chunk_size, get_max_file_size
bootinfo.max_file_size = get_max_file_size()
bootinfo.file_chunk_size = get_file_chunk_size()
for key in ("developer_mode", "socketio_port", "file_watcher_port"):
if key in frappe.conf:
bootinfo[key] = frappe.conf.get(key)

View file

@ -90,6 +90,10 @@ def get_max_file_size() -> int:
)
def get_file_chunk_size() -> int:
return cint(frappe.conf.get("file_chunk_size")) or 25 * 1024 * 1024
@frappe.whitelist()
def create_new_folder(file_name: str, folder: str) -> File:
"""create new folder under current parent folder"""

View file

@ -572,7 +572,7 @@ function return_as_dataurl() {
async function upload_file(file, i) {
currently_uploading.value = i;
const CHUNK_SIZE = 500 * 1024; // 500KB chunks
const CHUNK_SIZE = frappe.boot.file_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;