Skip to content

Function: getFileByPath()

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

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

Get a file by its path within a SharePoint drive.

Parameters

ParameterTypeDescription
clientClientThe Microsoft Graph client instance.
options{ driveId: string; filePath?: string; responseType?: ResponseType; }The file location options.
options.driveIdstringThe drive ID.
options.filePath?stringThe relative path to the file in the drive.
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 getFileByPath(client, {
  driveId: 'drive-id',
  filePath: 'Reports/2025/annual-summary.pdf',
  responseType: ResponseType.ARRAYBUFFER,
});
console.log('Downloaded', content.byteLength, 'bytes');

Matterway Assistant SDK Documentation