File Upload related cases in frappe

Please help/suggest to resolve below file upload cases in Frappe…

File Upload cases::

  1. Upload file on specific path/folder/different server drive , we do not want to upload in default folder
  2. We want to upload files to a remote file servers
    Create Dynamic folder path (if not exist) and uploads the files in that path, if path already exists the upload the file in that folder path
  3. Rename the file before uploading to remove the clash of file names in same folder

You can create custom scripts for the File doctype. You can examine the Frappe Drive code folder to examine it.

Also there is some integrations with NextCloud, Google Drive, Dropbox. Search for them in the forum and marketplace.

Lastly, if all fails I would integrate a custom solution with n8n.


I think you should consider something like this:

  1. On your frontend, client script or .js file … . Use FileUploader
new frappe.ui.FileUploader({
                method: 'testfile.handler.capture',
                make_attachments_public: "False",
                dialog_title: "Your title",
                disable_file_browser: "False",
                frm: frm,
                restrictions: {
                    allowed_file_types: [".pdf"]
                on_success (file) {
                        message:__('File uploaded.'),
                    }, 5);   


This code show dialog to attach the file and pass it to the backend.

  1. On your backend, create a method that manage this file as needed. This way:
def capture(file = None):
    file_content = frappe.local.uploaded_file
    file_name = frappe.local.uploaded_filename
    file_path = + "/" + file_name
    # your magic here to rename, check if file exists, change path ...

    with open(file_path, "wb") as file:

Hope this helps.