Appearance
Function: mwFileFromUrl()
ts
function mwFileFromUrl(ctx: Context, url: string): Promise<MwFile>;Defined in: src/file/getMwFile.tsx:357
Experimental
Fetch a file from a URL and return it as an MwFile.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | Context | Context object. |
url | string | URL of the file to fetch. |
Returns
Promise<MwFile>
An MwFile with the file data and metadata.
Example
ts
const catalog = await mwFileFromUrl(ctx, 'https://shop.example.com/product-catalog.pdf');
console.log('Downloaded', catalog.name, '(' + catalog.type + ')');