Choose where you’d like to start

Upload files 

Note: As previously announced, Zoho Docs is being discontinued and the Deluge Docs integration tasks will stop executing starting 15th September 2023. For your advanced file management and collaboration requirements, we recommend you refer to the WorkDrive API documents as an alternative.

Overview

This task is used to upload a file to the specified folder.

Syntax

<response> = zoho.docs.uploadFile(<fileDetails>, <folderID>, <workspaceID>);

where,

ParameterData typeDescription

<response>

KEY-VALUE

Variable which will hold the response returned by Zoho Docs.

<fileDetails>

MAP
(OR)
FILE
(OR)
TEXT

Content of the file can be in any of the following formats:

  • You can specify input.<file_upload_field> to upload the file given in the file upload field in Zoho Creator.
  • The content can be specified directly as TEXT by enclosing in double quotes. The file will be named as text by default.
  • The content can be specified directly as a MAP in the format:
    ​{"filename" : "​<name_of_the_file>", "content" : "<content_of_the_file>"}
Note: In Zoho Creator, the input file or the text that will be converted into a file cannot be more than 50 MB.

<folderID>

(optional)

TEXT

is the ID of the folder in Zoho Docs in which the file will be created.

The Folder ID can be viewed in the url when clicked on the folder in Zoho Docs.

Folder IDs are also present in the response of retrieveFiles() task and getFolders() task.

<workspaceID>

(optional)

TEXT

is the ID of the workspace in Zoho Docs in which the file will be created.

The Workspace ID can viewed in the url when clicked on the workspace in Zoho Docs.

Example: Upload a file in Zoho Docs

The following script uploads a file in Zoho Docs with the given content.

response= zoho.docs.uploadFile({"filename" : "test", "content" : "This is a test file"});

where,

"filename"
"content"

are keys to hold the file name and its contents.
"test"
"This is a test file"

values representing the file name and its contents.

Response

The success response returned is of the following format:


   "response":[ 
      { 
         "uri":"/files/v1/upload"
      },
      { 
         "message":"UPLOAD_SUCCESS"
      },
      { 
         "result":[ 
            { 
               "documentname":"test"
            },
            { 
               "uploaddocid":"h0tih1a1f38e022XXXXXXXX31f76b661f0c9d"
            }
         ]
      }
   ]
}

The ID of the uploaded file can be fetched using the following snippet:

info <response_variable>.get("response").get(2).get("result").get(1).get("uploaddocid");

Get Started Now

Execute