Choose where you’d like to start

Upload File In Zoho WorkDrive

Description

The zoho.workdrive.uploadFile task uploads a file to the specified folder in Zoho WorkDrive.

Syntax

<response> = zoho.workdrive.uploadFile(<file>, <folder_id>, <file_name>, <override_name_exist>, <connection>);

where:

 

ParamsData typeDescription
<response>KEY-VALUEThe details of the file that will be uploaded to the specified folder of Zoho WorkDrive.
<file>FILE

The file that will be uploaded.

Note: 

  • You can find the supported file types here.
  • The file is invoked from the cloud using the invokeUrl task. Click here to learn more about the invokeUrl task.
  • In Zoho Creator, the file uploaded in the file upload field can also be used as a value for this parameter.
  • In Zoho Creator, the size of the file cannot be more than 50MB.
<folder_id>TEXT

The ID of the folder to which the file will be uploaded.

Note: You can get the folder_id parameter from the Zoho WorkDrive URL. The URL will be in the following format:
https://workdrive.zoho.com/home/teams/<team_id>/privatespace/folders/<folder_id>
<file_name>TEXTThe name of the file should be URL encoded with UTF-8 Charset.
<override_name_exist>BOOLEAN

This parameter decides what will happen if a file with the same name already exists in the specified folder.

Allowed values:

  • true - existing file with the same name as the specified file name will be replaced by the new file
  • false - the file is uploaded as new
<connection>TEXT

The link name of the connection. 

Note:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory in order for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter until you manually delete the authtoken from accounts.
  • Scope required for this integration task: WorkDrive.files.CREATE
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

Example

Example 1

The following script uploads an encoded file to the specified folder in Zoho WorkDrive:

myurl = encodeUrl("book1.pdf");
sample_file = invokeUrl
            [ 
               url: "http://www.africau.edu/images/default/sample.pdf" 
               type: GET
            ];
response = zoho.workdrive.uploadFile(sample_file, "g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXXb0d05", myurl , false, "workdrive_connection");

where:

response
The KEY-VALUE response returned by Zoho WorkDrive. It represents the details of the file that will be uploaded.
sample_file
The FILE variable that holds the file that needs to be uploaded.
"g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXXb0d05"
The TEXT that represents the ID of the folder in which the file needs to be uploaded.
myurl
The TEXT that represents the name of the file that is URL encoded.
false
The BOOLEAN that represents how the file will not replace the existing file with the same name. Instead, it will be uploaded as new.
"workdrive_oauth_connection"

The TEXT that represents the connection link name.

Response Format

Success Response

  • The success response will be returned in the following format:

      {
      "data": [
      {
      "attributes": {
      "File INFO": "{\"RESOURCE_ID\":\"g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXX100c5\",\"LIBRARY_ID\":\"3uinyXXXXXXXXXXXXXXXXXXXXXXXXXXX428fd\",\"PARENT_MODEL_ID\":\"g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXXb0d05\",\"PARENT_ID\":\"g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXXb0d05\",\"RESOURCE_TYPE\":2001,\"WMS_SENT_TIME\":\"1566479972918\",\"OWNER\":\"667XXX621\",\"RESOURCE_GROUP\":\"FILE\",\"PARENT_MODEL_NAME\":\"file\",\"OPERATION\":\"UPLOAD\",\"EVENT_ID\":\"-1\",\"AUDIT_INFO\":{\"resource\":{\"owner\":\"667XXX621\",\"created_time\":1566479972495,\"creator\":\"662607120\",\"service_type\":1,\"extension\":\"txt\",\"resource_type\":2001,\"name\":\"sample.txt\"},\"parentInfo\":{\"parentName\":\"Folder 1\",\"parentId\":\"g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXXb0d05\",\"parentType\":1001},\"libraryInfo\":{\"libraryName\":\"MYSPACE_LIBRARY\",\"libraryId\":\"3uinyXXXXXXXXXXXXXXXXXXXXXXXXXXX428fd\",\"libraryType\":20},\"statusCode\":\"D201\"},\"ZUID\":662607120,\"TEAM_ID\":\"6oq3dXXXXXXXXXXXXXXXXXXXXXXXXXXX4a777\"}",
      "parent_id": "g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXXb0d05",
      "FileName": "sample.txt",
      "resource_id": "g4xh1XXXXXXXXXXXXXXXXXXXXXXXXXXX100c5"
      },
      "type": "files"
      }
      ]
      }

Failure Response

  • The failure response for an incorrect folder ID will be returned in the following format:

      {
      "errors": [
      {
      "id": "F6003",
      "title": "Invalid Param found"
      }
      ]
      }

Related Links

Get Started Now

Execute