Task: files region on v2
Author: shariquerikCreated Sep 18, 2026Updated Sep 18, 2026
Labelswayfinder:task
Ticket of Desk v2 — REST API v2 everywhere. The shape is fixed in the files grilling's resolution; do not re-open it. Wrapper: @framework/ui/api (PR #42947). Skills: /frappe-app-dev + /code-style for code, /quality-code-review in a fresh subagent before closing.
Question
Move the files region onto v2 as ruled. Two PRs:
- Framework half on
develop(frappe/api/v2.py, tests beside the other v2 route tests):POST /document/Fileaccepts multipart: partfileplus File fields as form fields; runs the permission check, chunk handling (chunk_index,total_chunk_count,chunk_byte_offset,total_file_size; a non-final chunk returns{"data": null}), image optimize andafter_file_uploadhooks thatfrappe.handler.upload_fileruns today; returns the File document. JSON with base64contentkeeps working.POST /document/<dt>/<name>/attachments(same handler,attached_to_*fixed from the URL) andDELETE /document/<dt>/<name>/attachments/<file name>(callsfrappe.delete_doc("File", …)); both return the refreshedattachmentspart.- The
attachmentspart gainscreationandowner(frappe.desk.form.load.get_attachments). frappe/api/__init__.pypasses a file response through (frappe.response.typeindownload/binary) instead of alwaysbuild_response("json"), sodownload_templateand its siblings stream on the v2 method route.
- Desk and
ui/half ondesk-v2:ui/src/components/FileUpload/useFileUpload.ts: the transport sends multipart to/api/v2/document/Filethrough the wrapper (small and chunked paths alike, drop the frappe-uiuseFileUploaddelegate), readsdata.file_url, takesfile_chunk_sizeandmax_file_sizeby injection from the session/boot object, neverfrappe.boot.ui/src/components/DataImport/UploadStep.vueandTemplateModal.vue: upload through the same transport; template download through the wrapper as a streamed GET on the v2 method route.- Wrapper gains
uploadFile(file, fields, {onProgress, signal}),attachFile(doctype, name, file, …),removeAttachment(doctype, name, fileName),downloadFile(url)(streamed). AttachmentsList.vueremoval callsremoveAttachmentwhere a record is known.
Done when both PRs are merged, no /api/method literal or frappe-ui fetch primitive remains in the files above, and the review gates ran.
Source: frappe/frappe