File Handling
You can create, get, and delete files and attach them to messages and posts
File Model
Name | Data Type | Description |
|
| Root file key on cloud storage |
|
| HTTP link for file download |
|
| File type |
|
| Date/time when a file is uploaded |
|
| Date/time when a file is updated |
|
| 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:
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:
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.
Otherwise, if an error is encountered during the deletion, it will return the following errors:
Last updated