Storage API
Storage API allows to store any kind of files in the ConnectyCube cloud. Mainly it is used for chat attachments, users avatars, group chat pictures.
All files in the ConnectyCube are named as blobs - binary large object. It is a data type that can store binary objects or data.
File model
Parameter | Description |
---|---|
id | FIle identifier |
created_at | Date and time when file was created. System creates this parameter automatically |
updated_at | Date and time when file was updated. System creates this parameter automatically |
name | File name, the lenth can be min 1 char and max 100 chars |
status | (deprecated) Status of file, can be ‘null’ or ‘complete’ |
public | File availability / access. Can be public or private. By default all created files are private |
uid | Unique identifier that points to an object in Amazon S3 service. Mainly used to download file content. |
content_type | Type of file. Format: mime type |
size | File size |
blob_object_access | Data that are used for upload or download file |
last_read_access_ts | (deprecated) Last date and time when the file was accessed |
set_completed_at | (deprecated) Date and time when ‘Completed’ status was set for a file with ‘Declaring file uploaded’ request |
File upload flow
The complete file upload flow looks as follow:
Create a file
With a create a file request a new file can be created on server and used in the application. To create a new file at least two mandatory parameters content_type
and name
should be set to identify what file will be created.
As a response, created file will receive blob_object_access
parameter with a link on Amazon S3 service where this file will be stored.
Endpoint
Parameters
Parameter | Required | Description |
---|---|---|
blob[content_type] | Yes | Mime content type. This is a type of file to create, it can be image, video, audio, etc. |
blob[name] | Yes | Name of a new file |
blob[public] | No | File visibility. Can be public or private. By default all created files are private (blob[public]=false ) |
Request example
Response
Upload a file
Upload a file with the parameters taken from blob_object_access
field from create a file response.
Note: The maximum size of the uploaded file is 100 Mb.
Endpoint
Parameters
Use parameters and URL from blob_object_access
received as a response for Create a file request. The complete list pf parameters can vary.
Parameter | Value |
---|---|
Content-Type | image/jpg |
Expires | Fri, 23 Nov 2018 15.30.33 GMT |
acl | public-read |
key | c44be580f3294f1ca18056d62f75864500 |
policy | eyJleHBpcmF0aW9…OVoifV19 |
success_action_status | 201 |
x-amz-algorithm | AWS4-HMAC-SHA256 |
x-amz-credential | AKIAIG3WPT7RALYOZW6Q/20181123/us-east-1/s3/aws4_request |
x-amz-date | 20181123T141009Z |
x-amz-signature | 6b76f67cc72313fd5c1f39a75af3ec99bc7363cc6db1adf7e9e0d73091c05299 |
file | root to the profile_image.jpg |
Request example
Response
Declare file uploaded
Declaring file as uploaded by set a ‘Complete’ status for the uploaded file.
Endpoint
Parameters
Parameter | Required | Description |
---|---|---|
blob[size] | Yes | Size of the uploaded file, in bytes |
Request example
Response
Get information about file by ID
Retrieving of information about file by specifying its ID.
Endpoint
Request example
Response
Get files list (deprecated)
Get list of files created by the current user. User ID is taken from the token specified in the request.
Endpoint
Parameters
Parameter | Required | Description |
---|---|---|
page | No | Number of page to show. The first page is shown by default |
per_page | No | Number of results to show per page. Default number of results per page - 10, maximum number of results per page - 100 |
Request example
Response
Download file by UID
Download file (get file as a redirect to the S3 object) by its UID. UID
is a parameter created by system automatically with a ‘create a file’ request. Only file set as complete can be downloaded.
All public file (blob[public]=true
) can be downloaded without a session token.
Endpoit
Request example
Response
Get file object by UID
Retrieving of information about file by specifying its UID.
Endpoint
Parameters
Parameter | Required | Description |
---|---|---|
download_url | No | include download url to response |
Request example
Response
Edit a file (deprecated)
Update one or more parameters of the file.
Endpoint
Parameters
Parameter | Required | Description |
---|---|---|
blob[content_type] | Optional | Type of file, format: mime content type |
blob[name] | Optional | File name with a length up to 100 chars |
blob[new] | Optional | Set to ‘1’ if file content should be changed |
Request example
Response
Delete a file
Delete a file from server by its ID.