TwentyThree Developer APIAPI Method: /api/action/upload

API Method: /api/action/upload

Last updated on April 6, 2016.

Upload a file for a an action variable.

Parameters

ParameterDescription
file (required)The file to upload.
action_id (required)To action to upload content to.
variable_name (required)The action variable to upload the file to.

Parameters for Resumable.js

This API method support an extra set of parameters designed to work with Resumable.js, an open sourced JavaScript library for providing multiple simultaneous, stable, fault-tolerant and resumable uploads via the HTML5 File API released by TwentyThree.

To handle the state of upload chunks, a number of extra parameters are sent along with such requests:

  • resumableChunkNumber: The index of chunk in the current upload. First chunk is 1 (no base-0 counting here).
  • resumableChunkSize: The chunk size in bytes.
  • resumableTotalSize: The total file size in bytes.
  • resumableIdentifier: A unique identifier for the file contained in the request.

API methods expect all chunks of a file to be uploaded before the file is added to the archive. When the last chunk's upload completes, the messages listed in the Returns section applies. For all other chunk, HTTP status codes control the flow:

  • 200: The chunk was accepted and correct. No need to re-upload.
  • 500: The file for which the chunk was uploaded is not supported, cancel the entire upload.
  • Anything else: Something went wrong, but try reuploading the file.

Permission level

The minimum required permission level is:

read

Example XML Response

<response status="ok" permission_level="write" 
  message="The action was updated" cached="0">

Example JSON Response

{
  "status": "ok", 
  "message":"The action was updated",
  "permission_level":"write",
  "cached":"0",
  "album":{},
  "p": "1",
  "size": "1",
  "site": { ...},
  "endpoint": "/api/album/upload"
}