Skip to main content

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

ParameterTypeDescription
ctxContext
fileUrlstringThe url from which to fetch the file.
headersHeader(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);