Browse SDKs · React Native
SDKsReact Native

Create a file message from a URL

OpenIM React Native SDK guide for create a file message from a url.

Copy

Use createFileMessageByURL() to create a message from uploaded file resource information.

const message = await OpenIMSDK.createFileMessageByURL({
  filePath: '',
  fileName: 'product-guide.pdf',
  uuid: 'file-001',
  sourceUrl: 'https://www.example.com/product-guide.pdf',
  fileSize: 256000,
  fileType: 'application/pdf',
});

Parameters

ParameterTypeRequiredDescription
filePathstringYesLocal file path. Pass an empty string when only a remote resource is available.
fileNamestringYesFile name shown to recipients.
uuidstringYesFile resource ID.
sourceUrlstringYesURL of the uploaded file.
fileSizenumberYesFile size in bytes.
fileTypestringNoFile type.

The call returns a MessageItem ready to send. Use the actual upload result for resource information, then use Send an uploaded media message.