File Handling
You can create, get, and delete files and attach them to messages and posts

File Model

Name
Data Type
Description
fileId
String
Root file key on cloud storage
fileUrl
String
HTTP link for file download
type
enum
File type
createdAt
String($date-time)
Date/time when a file is uploaded
updatedAt
String($date-time)
Date/time when a file is updated
attributes
Object
Information about the file

Upload Files

Before you can attach files in messages, posts user and community avatars, you need to create the file first using the createFile, createImage or createVideo methods.
In case you're using sdk with React Native you should use react-native-formdata-polyfill

Upload Image

Requirements for Images:

  • Supported image types are JPG and PNG.
  • The maximum file size of the image is 1 GB.

Upload Video

The fileObject is the object returned by the API as a result of selecting and uploading files using the input element. It represents the uploaded file. Check the File web documentation for more information on file objects.
Refer to the file model for the structure and information of the response after a successful file creation. Take note of the fileId as it is a needed parameter for getting and deleting files.
If an error is encountered while creating the file, it will return the following errors:
//Attached file payload is too large
{
"status": "error",
"code": 500000,
"message": "Payload too large."
}
// Unexpected error
{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}

Get Download File Information

File/Image/Video

You can get the file information using the getFile method. Provide the fileId of the file that you want to get. The fileId is retrieved from the response after successfully creating the file.
If a file is successfully retrieved, the response will contain the file details. Refer to the file model for the structure and information of the response after a successful file query. If the file is not found, it will return the following error:
//Resource Not Found error
{
"status": "error",
"code": 400400,
"message": "Resource Not Found."
}

Observe File

Delete File

To delete a file, use the deleteFile method and pass the fileId of the file that you want to delete as the parameter. The fileId is retrieved from the response after successfully creating the file.
The response will return true if the file deletion is successful.
"data": {
"success": true
}
Otherwise, if an error is encountered during the deletion, it will return the following errors:
//Permission denied error
{
"status": "error",
"code": 400301,
"message": "Permission denied"
}
Resource Not Found error
{
"status": "error",
"code": 400400,
"message": "Resource Not Found."
}
//Passed the wrong parameters error
{
"status": "error",
"code": 500000,
"message": "Parameters error."
}
Export as PDF
Copy link
Outline
File Model
Upload Files
Upload Image
Upload Video
Get Download File Information
Observe File
Delete File