Appearance
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
| Parameter | Type | Description |
|---|---|---|
client | Client | The Microsoft Graph client instance. |
options | { driveId: string; filePath?: string; responseType?: ResponseType; } | The file location options. |
options.driveId | string | The drive ID. |
options.filePath? | string | The relative path to the file in the drive. |
options.responseType? | ResponseType | The 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');