The upload of videos is initiated through a POST request in the route <code>/v1/videos</code> This route will only be used to create the upload, and not for the upload itself. From the call of this route, data will be returned in the HEADERS of the response that will be used to perform the upload.

 

The upload itself will be done via the /v1/videos/uploads/:id route

 

Currently the API does not accept more than one upload at a time.

Creating the Upload – POST

Route

Method Route Description
POST /v1/videos Route for creating the upload.

* Token generated by the authentication route

Headers

Param Type Description Required
Tus-Resumable String TUS protocol version. Always send 1.0.0 Yes
Upload-Length Number Size of the file to be uploaded (In bytes). Yes
Upload-Metadata String “filename” followed by the base64 filename.
Ex.: File name: test_converted=> Upload-Metadata: filename dGVzdGUubXA0.
Yes
Content-Type String application/json No
gallery String Uuid of the gallery that will be uploaded later. No
Authorization String Token authorization. Yes

Response

– Response when performing an upload (Status: 201)

Name Value
X-Powered-By Express
Tus-Resumable 1.0.0
Access-Control-Expose-Headers Authorization, Content-Type, Location, Tus-Extension, Tus-Max-Size, Tus-Resumable, Tus-Version, Upload-Defer-Length, Upload-Length, Upload-Metadata, Upload-Offset, X-HTTP-Method-Override, X-Requested-With
Location //localhost:15214/v1/videos/uploads/410b471ac3ed2ee0f8856e7aa4358ba4
Content-Length 0
Date Tue, 21 Jun 2022 13:09:10 GMT
Connection keep-alive
Keep-Alive timeout=5

– Error response when not sending required field or field in incorrect format (Status: 400)

{
   "error": "Bad Request"
}

– Error response when trying to perform more uploads at a time per application (Status: 429)

{
   "error": "Too many simultaneous uploads, please send one file at a time"
}

– Error response for some internal error (Status: 500)

{
  "error": "Internal Server Error"
}

Upload – PATCH

Route

Method Route Description
PATCH /v1/videos/uploads/:id Route to upload.

NOTE: In this request, the video specified in Upload-Metadata must be passed in its binary form. As an example, in Insomnia, it would be selecting the ‘file’ option, and then selecting the ‘Binary file’ option, and then selecting the desired file.

Headers

Param Type Description Required
Tus-Resumable String TUS protocol version. Always send 1.0.0 Yes
Content-Length Number Amount in bytes remaining to be uploaded. Yes
Upload-Offset Number Initial byte for the upload (If it is the first request, it must start with 0, if the upload has been interrupted, the upload must continue where it left off, this information is provided by the Upload-Offset parameter returned in the HEAD / v1/videos/uploads/:id). Yes
Upload-Metadata String “filename” followed by the base64 filename. Ex.: File name: test_converted=> Upload-Metadata: filename dGVzdGUubXA0. Yes
Content-Type String application/offset+octet-stream Yes
gallery String Uuid of the gallery that will be uploaded later. No
Authorization String Token authorization. Yes

Response

– Response header when uploading (Status: 201)

Name Value
X-Powered-By Express
Tus-Resumable 1.0.0
Access-Control-Expose-Headers Authorization, Content-Type, Location, Tus-Extension, Tus-Max-Size, Tus-Resumable, Tus-Version, Upload-Defer-Length, Upload-Length, Upload-Metadata, Upload-Offset, X-HTTP-Method-Override, X-Requested-With
Location //localhost:15214/v1/videos/uploads/410b471ac3ed2ee0f8856e7aa4358ba4
Content-Length 0
Date Tue, 21 Jun 2022 13:09:10 GMT
Connection keep-alive
Keep-Alive timeout=5

– Error response when not uploading-metadata correctly (Status: 400)

{
    "error": "Bad Request"
}

– Error response when trying to perform more uploads at a time per application (Status: 429)

{
    "error": "Too many simultaneous uploads, please send one file at a time"
}

– Error response for some internal error (Status: 500)

{
  "error": "Internal Server Error"
}

Returns information from the Upload – HEAD

Route

Method Route Description
PATCH /v1/videos/uploads/:id Route to upload.

Headers

Param Type Description Required
Authorization String Token authorization. Yes
Tus-Resumable String TUS protocol version. Always send 1.0.0 Yes

Response

NOTE: The Upload_Offset parameter returned indicates how many bytes have already been sent, when the Upload-Offset is equal to the Upload-length, the upload is completed.

– Response header when uploading (Status: 201)

Name Value
X-Powered-By Express
Tus-Resumable 1.0.0
Access-Control-Expose-Headers Authorization, Content-Type, Location, Tus-Extension, Tus-Max-Size, Tus-Resumable, Tus-Version, Upload-Defer-Length, Upload-Length, Upload-Metadata, Upload-Offset, X-HTTP-Method-Override, X-Requested-With
Location //localhost:15214/v1/videos/uploads/410b471ac3ed2ee0f8856e7aa4358ba4
Content-Length 0
Date Tue, 21 Jun 2022 13:09:10 GMT
Connection keep-alive
Keep-Alive timeout=5

– Error response for some internal error (Status: 500)

{
  "error": "Internal Server Error"
}