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 has created only a pending message object. Because the resource has already been uploaded, send it with sendMessageNotOss().
Was this page helpful?