#42992·frappe

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:

  1. Framework half on develop (frappe/api/v2.py, tests beside the other v2 route tests):
    • POST /document/File accepts multipart: part file plus 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 and after_file_upload hooks that frappe.handler.upload_file runs today; returns the File document. JSON with base64 content keeps working.
    • POST /document/<dt>/<name>/attachments (same handler, attached_to_* fixed from the URL) and DELETE /document/<dt>/<name>/attachments/<file name> (calls frappe.delete_doc("File", …)); both return the refreshed attachments part.
    • The attachments part gains creation and owner (frappe.desk.form.load.get_attachments).
    • frappe/api/__init__.py passes a file response through (frappe.response.type in download/binary) instead of always build_response("json"), so download_template and its siblings stream on the v2 method route.
  2. Desk and ui/ half on desk-v2:
    • ui/src/components/FileUpload/useFileUpload.ts: the transport sends multipart to /api/v2/document/File through the wrapper (small and chunked paths alike, drop the frappe-ui useFileUpload delegate), reads data.file_url, takes file_chunk_size and max_file_size by injection from the session/boot object, never frappe.boot.
    • ui/src/components/DataImport/UploadStep.vue and TemplateModal.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.vue removal calls removeAttachment where 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.