Browse SDKs · Flutter
Platform
SDKsFlutter

Upload file

Upload a local file to storage using the OpenIM Flutter SDK.

Copy

Upload a local file directly to object storage for user avatars, group avatars, or custom business attachments:

Parameters

ParameterTypeRequiredDescription
idStringYesUnique task ID used to correlate progress and completion events in listener callbacks.
filePathStringYesAbsolute local path of the file accessible by the client.
fileNameStringYesOriginal file name, including its extension.
contentTypeString?NoMIME type of the file (for example, image/png).
causeString?NoBusiness 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.