SDKsFlutter
Upload a file
Use the Flutter SDK to upload a file independently of messaging.
Independent uploads can be used for user avatars, group avatars, profile attachments, or other business files. They do not belong to messaging. Generate a stable business id to associate each upload task with listener callbacks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Stable business ID that associates the task with its listener. |
filePath | String | Yes | File path readable on the current platform. |
fileName | String | Yes | Original file name. |
contentType | String? | No | MIME type. |
cause | String? | No | Application-defined reason for the upload. |
await OpenIM.iMManager.uploadFile(
id: uploadID,
filePath: filePath,
fileName: fileName,
contentType: contentType,
cause: 'user-avatar',
);The Future, progress callbacks, and completion callback are separate stages. Use the URL from the completion callback to update an avatar or another business resource. This method does not automatically update a profile, create a message, or send a message. See setUploadFileListener() for the single listener setup.
Was this page helpful?