Browse SDKs · Flutter
SDKsFlutter

Upload a file

Use the Flutter SDK to upload a file independently of messaging.

Copy

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

ParameterTypeRequiredDescription
idStringYesStable business ID that associates the task with its listener.
filePathStringYesFile path readable on the current platform.
fileNameStringYesOriginal file name.
contentTypeString?NoMIME type.
causeString?NoApplication-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.