Files are an essential component of modern software applications. Amity provides a powerful file management system that enables you to easily handle different types of files, such as document files, videos, and audio files. In this section, we will introduce you to the concept of a file in Amity and provide an overview of file handling in Amity.
Property | Description |
---|---|
To upload a file to the system, you can use the Amity File Upload API provided by the SDK. The API allows you to upload a file to the Amity server by providing the file's data and the file metadata, such as the file name, file type, and file size. The SDK simplifies the process of uploading files by providing pre-built components that you can easily integrate into your application.
On Android, you can separately observe uploading states outside of the uploading method by using:
Version 6 and Beta(v0.0.1)
You can retrieve a file from Amity using the Amity File Retrieval API provided by the SDK. The API enables you to retrieve a file from the Amity server by supplying the file ID. The SDK streamlines the process of retrieving files by offering pre-made components that can be smoothly integrated into your app.
In addition to uploading and retrieving files, Amity provides a deleting function to delete a file that is no longer needed.
The response will return true
if the file deletion is successful.
Version 6 and Beta(v0.0.1)
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:
File upload and download are key features of our product, which enable developers to easily incorporate file-sharing functionality into their applications. With support for a wide range of file types, including images, videos, audio, and documents, developers can create highly engaging and interactive user experiences that drive engagement and increase retention. The maximum file size of a file regardless of its type is 1 GB.
By enabling users to share files directly within the chat or social feed, developers can create highly personalized and engaging experiences that foster deeper connections among users. For example, users can share photos and videos with friends and family, or exchange documents and other files within a community. To support various use cases and make it easy to handle files, images, and videos, we offer convenient methods for managing these types of content:
The SDK does not manage the caching of any images or files. It is recommended to effectively handle caching to ensure optimal performance. You can use a pre-existing implementation or library to handle the caching of files or images.
fileId
Root file key on cloud storage
fileUrl
HTTP link for file download
type
File type
createdAt
Date/time when a file is uploaded
updatedAt
Date/time when a file is updated
attributes
Information about the file
The video data is the representation of the video that has been uploaded using the SDK. The uploaded video will be transcoded to other different resolutions depending on console settings. Below is a table of properties that it contains.
Property | Description |
---|---|
The fileUrl
and videoUrl.original
provides the URL of the same video resolution.
The difference being, fileUrl
returns the actual file format while videoUrl.original
returns MP4 format.
To upload a video to the system, you can use the Amity Video Upload API provided the SDK. The API allows you to upload a video to the Amity server. The SDK simplifies the process of uploading videos by providing pre-built components that you can easily integrate into your application.
Supported ✅ (please wait while we prepare a real example!)
Version 6 and Beta(v0.0.1)
If an error is encountered while creating the file, it will return the following errors:
Once you uploaded a video the videos undergo transcoding from their original resolution. You can quickly access the original size of the video right after you make the video message. However, it takes time for the transcoded resolutions to be ready. Here are the available transcoded resolutions.
1080p
720p
480p
360p
original
Supported ✅ (please wait while we prepare a real example!)
Here's an example of getting a specific video resolution from a post.
Additionally, you can display a video preview in the user interface by utilizing a video thumbnail image. This allows for a more visually appealing representation of the video and provides a quick preview for users before they choose to view the full video. The thumbnail may not immediately available after the video was uploaded. However, eventually, the thumbnail will be become available.
Supported ✅ (please wait while we prepare a real example!)
Supported ✅ (please wait while we prepare a real example!)
The functionality isn't currently supported by this SDK.
The use of images as a visual representation of information is crucial in many software applications. Our SDK provides the tools and functionality needed to easily handle images. In this section, we will introduce you to image handling in Amity, including how to upload and retrieve images in the SDK.
Property | Description |
---|---|
To upload an image to the system, you can use the Amity Image Upload API provided by the SDK. The API allows you to upload an image to the Amity server/ The SDK simplifies the process of uploading images by providing pre-built components that you can easily integrate into your application.
Supported ✅ (please wait while we prepare a real example!)
Supported image formats are JPG, PNG and cannot exceed 1GB in size.
You can retrieve an image from Amity using the Amity Image Retrieval API provided by the SDK. The API enables you to retrieve an image from the Amity server by supplying the image URL. Once an image is uploaded to the server, the image will be automatically transformed into four different sizes for versatile usage. We provided an option to retrieve a specific image size which are:
Small: is used for image thumbnails, with a maximum image size of 160 pixels per dimension. For example, this should be used for small previews in an image gallery that displays a large number of images in a grid.
Medium: is used for standard image display, with a maximum image size of 600 pixels per dimension.
Large: is used for full-screen image display, with a maximum image size of 1500 pixels per dimension.
Supported ✅ (please wait while we prepare a real example!)
Supported ✅ (please wait while we prepare a real example!)
fileId
Identifier for the uploaded file
fileUrl
The HTTP web URL for the uploaded file. You can use this fileUrl
for downloading the original video file. (The file format remains unchanged)
attributes
Contains a dictionary with values for name
, extension
, size
and mimeType
of uploaded video.
attributes.metadata
Contains a dictionary with values for video
and audio
of uploaded video.
attributes.metadata.video
Contains a dictionary with values for width
, height
, duration
, bit_rate
, avg_frame_rate
and display_aspect_ratio
attributes.metadata.audio
Contains a dictionary with values for duration
, bit_rate
and sample_rate
videoUrl
After video uploaded and transcoded by the server. The video data will contain videoUrl
that provides different video URLs for each resolution.
original - the equivalent resolution to fileUrl
1080p - 1920×1080 in horizontal, and 1080x1920 in vertical
720p - 1280×720 horizontal, and 720x1280 in vertical
480p - 640x480 horizontal, and 480x640 in vertical
360p - 480x360 horizontal, and 360x480 in vertical
(All transcoded videos are in MP4 format)
status
An enum represents 4 video statues
uploaded - the video is uploaded and users can watch the original raw file on fileUrl
transcoding - the video is being transcoded to pre-defined resolutions
transcoded - the video is transcoded and the resolutions are provided to videoUrl
error - the video encounters an issue while transcoding
fileId
Identifier for the uploaded file
fileUrl
The HTTP web URL for the uploaded file. You can use this fileUrl
for downloading the image file.
attributes
Contains a dictionary with values for name
, extension
, size
& mimeType
of uploaded image
metadata
Contains additional metadata dictionary related to uploaded image such as height
, width
, isFullImage
etc.