Skip to content

Function: getFile()

ts
function getFile(client: Client, options: {
  driveId: string;
  fileId: string;
  responseType?: ResponseType;
}): Promise<any>;

Defined in: src/ms-graph/sharepointGraph.ts:196

Get file content from a SharePoint drive.

Parameters

ParameterTypeDescription
clientClientThe Microsoft Graph client instance.
options{ driveId: string; fileId: string; responseType?: ResponseType; }The file location options.
options.driveIdstringThe drive ID.
options.fileIdstringThe file ID.
options.responseType?ResponseTypeThe response type. Defaults to ResponseType.ARRAYBUFFER.

Returns

Promise<any>

The file content in the requested format.

Example

ts
const client = await getMsGraphClient(creds);
const content = await getFile(client, {
  driveId: 'drive-id',
  fileId: 'file-id',
  responseType: ResponseType.ARRAYBUFFER,
});
console.log('Downloaded', content.byteLength, 'bytes');

Matterway Assistant SDK Documentation