sdk.automation.getdatafromfile
Home > @matterway/sdk > Automation > getDataFromFile
Automation.getDataFromFile() function
Fetchs a URL and returns the response body as a base64 string.
Signature:
export declare function getDataFromFile(ctx: Context, fileUrl: string, headers?: Header): Promise<Base64Data>;
Parameters
Parameter | Type | Description |
---|---|---|
ctx | Context | |
fileUrl | string | The url from which to fetch the file. |
headers | Header | (Optional) Headers are key value pairs spread to override headers sent in request. |
Returns:
Promise<Base64Data>
The file as a Base64 string.
Example 1
const file = await getDataFromFile('https://example.com/file.zip');
Example 2
const file = await getDataFromFile('https://example.com/file.zip', {
authorization: 'Bearer AbCdEf123456',
});
const contents = await downloadFile(file);