SDKsWASM
Create a file message from a URL
Create a file message from an uploaded resource URL with the WASM SDK.
createFileMessageByURL() creates a message from information for a file that has already been uploaded.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Local filename or application-defined path of the file. Pass an empty string when only a remote resource is available. |
fileName | string | Yes | Filename displayed to users. |
uuid | string | Yes | Unique identifier for the file resource. |
sourceUrl | string | Yes | Accessible URL of the uploaded file. |
fileSize | number | Yes | File size in bytes. |
fileType | string | No | File MIME type. |
const { data: message } = await openimsdk.createFileMessageByURL({
filePath: '',
fileName: 'report.pdf',
uuid: crypto.randomUUID(),
sourceUrl: uploaded.url,
fileSize: uploaded.size,
fileType: 'application/pdf',
});The filename, size, type, and URL must come from the actual upload result. Pass an empty string for filePath when only a remote resource is available. When the Promise resolves, it returns a pending MessageItem object. Next, deliver the message to the target conversation using Send pre-uploaded media messages.
Was this page helpful?