SDKsFlutter
Upload file
Upload a local file to storage using the OpenIM Flutter SDK.
Upload a local file directly to object storage for user avatars, group avatars, or custom business attachments:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Unique task ID used to correlate progress and completion events in listener callbacks. |
filePath | String | Yes | Absolute local path of the file accessible by the client. |
fileName | String | Yes | Original file name, including its extension. |
contentType | String? | No | MIME type of the file (for example, image/png). |
cause | String? | No | Business reason or description for the upload (for example, user-avatar). |
Code example
await OpenIM.iMManager.uploadFile(
id: 'upload_task_001',
filePath: filePath,
fileName: fileName,
contentType: contentType,
cause: 'user-avatar',
);Return value
A successful Future returns void, indicating that the upload task was accepted and started.
Upload progress and the resulting file URL are delivered through the global upload listener. Once the complete callback provides the remote URL, pass it to subsequent profile update or attachment storage APIs. Calling uploadFile does not automatically update user profiles or generate chat messages.
For listener configuration and callback signatures, see Listen for file upload progress.
Was this page helpful?