Image/File · Standard API · eKYC Core

Upload video/audio/frames

POST/v1/files

Uploads a video or audio file, or a list of video frames, and returns the file_id for it.

Request

MethodPOST
Path/v1/files
Content-Typemultipart/form-data
Auth requiredYes — HMAC signing

There are two ways to call this, and they take different parameters and different content types.

NameTypeRequiredDescription
filefileOptionalthe file video/audio to be uploaded
labelstringOptionallabel of the file
metadatastring_jsonOptionalkey-value, key should be string, value should be string, int, float, bool, for example "{\"id\":\"123456789\",\"type\":1}". If the content-type is application/json, metadata should be key-value string, for example {"id":"123456789", "type": 1}
parent_idstringOptionaluuid of the parent of the file
frames[]FrameDataOptionallist of video frames to be uploaded
  • Upload video/audio — file, label are required and content-type must be multipart/form-data. If you use file, label, metadata, omit parameter frames.
  • Upload video frames — frames is required and content-type must be application/json. If you use frames, metadata, omit parameter file, label.

The label parameter

label says which kind of file is being uploaded.

labelDescription
videothe video file
audiothe audio file

The frames parameter

Each entry in frames is a FrameData object:

NameTypeRequiredDescription
base64stringOptionalbase64 encoded text of image data
labelstringOptionallabel of the image as described at Label table
indexintOptionalthe index of this frame in the video
metadatastring_jsonOptionalkey-value, key should be string, value should be string, int, float, bool, for example "{\"id\":\"123456789\",\"type\":1}". If the content-type is application/json, metadata should be key-value string, for example {"id":"123456789", "type": 1}

Sample request

curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/files \
-H 'Authorization: TV <YOUR ACCESS KEY>:<CREATED SIGNATURE>' \
-H 'X-TV-Timestamp: 2019-04-21T18:00:15+07:00' \
-F 'file=@"videos/frames.mp4"'
-F 'label="video"'

Response

data.file_id is the id of the stored file.

JavaScript
{
  "data": {
    "file_id": string, // ID of the uploaded file in StoreDB
  },
  "errors": [
      {
        "code": string,
        "message": string,
        "detail": {
            "field": string, // optional, which parameter is invalid.
            ... // any other information that can be useful for client
        },
      },
      ... // other errors
  ]
}

On success the HTTP status code is 200 and data holds:

NameTypeDescription
file_idstringID of the uploaded file (UUID)

A successful upload comes back like this:

JSON
{
  "data": {
    "file_id": "20b457d2-cf11-4c2b-a491-8137ae6b0bc8"
  }
}

Failure codes

In case of error, the data will be empty, and server sends following HTTP status code and error information:

HTTP codeError codeDescription
400invalid_parameter_exceptionInput parameter violates a constraint.
400request_time_too_skewedThe X-TV-Timestamp header is expired, need a newer one.
401access_denied_exceptionYou are not authorized to perform the action.
404image_not_found_exceptionThe image ID is not found in DB.
408request_timeout_exceptionRequest takes too long to process
413file_too_large_exceptionThe input file size exceeds the allowed limit (15MB).
429rate_limit_exceptionThe number of requests exceeded your throughput limit.
500internal_server_errorSome unexpected error occurs while processing the request

The codes above are the ones documented for this endpoint. Response errors on the Overview lists the codes for the eKYC Core surface as a whole — the two lists do not match on every endpoint.