Tuyu Developers

Developers

Customize the URLs on this site with your Tuyu URL:

https:// .
Method Documentation > Files and Folders

File Upload POST

Description

Uploads a file to a specified location. No notifications are sent via this handler, please use file_send to send a notification following a successful upload.

URL

All responses are in JSON format by default, to specify an XML response add “.xml” to the end of the method name (in this case “file_upload”)

https://<your subdomain>.<your domain>/api/file_upload

Restrictions

The calling user must have:

  • Access to the file upload location.
  • Upload permissions in the file upload location.

Parameters

Bold indicates required

Parameter Description
api_key Your API Key.
comment A comment about the file
file Post data of the file.
file_id_tag A File ID tag for the file.
overwrite Default is 0, which will not overwrite a file with the same name in the same location and return an error if a file with same name is found. If value equals 1 any file with the same name will be overwritten with this file.
path Location where file will be uploaded. NOTE: This value must be URL-encoded. All paths must begin and end with “/”, with the exception of admins uploading into the site root, in which the path is simply “/”. Specific paths can be retrieved from file_list.
timestamp The current time in Unix timestamp format.
signature Please see “User Authentication” for more information.

Sample Response

A successful response will include the newly uploaded file's ID, name, and size which can be passed to file_send if the user wishes to send an upload notification.

Successful response In JSON:

{"fileInfo":{"fileId":1071266,"path":"\/","fileName":"recording.aiff","fileSize":29117258}}

Successful response in XML:

<fileInfo>
    <fileId>1071267</fileId>
    <path>/</path>
    <fileName>image.png</fileName>
    <fileSize>315392</fileSize>
</fileInfo>

Error response In JSON:

{"error":{
    "title":"File Cannot Be Overridden",
    "message":"You have selected “overwrite” to be false and this file already exists in this location."}
}

Error response In XML:

<error>
    <title>File Cannot Be Overridden</title>
    <message>You have selected “overwrite” to be false and this file already exists in this location.</message>
</error>