Skip to content

Function: copyFile()

ts
function copyFile(client: Client, options: {
  fileId: string;
  driveId: string;
  destinationFolderId: string;
  destinationDriveId: string;
  name: string;
}): Promise<void>;

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

Copy a file to another location in SharePoint.

Parameters

ParameterTypeDescription
clientClientThe Microsoft Graph client instance.
options{ fileId: string; driveId: string; destinationFolderId: string; destinationDriveId: string; name: string; }The copy options.
options.fileIdstringThe source file ID.
options.driveIdstringThe source drive ID.
options.destinationFolderIdstringThe destination folder ID.
options.destinationDriveIdstringThe destination drive ID.
options.namestringThe name for the copied file.

Returns

Promise<void>

A promise that resolves when the copy completes.

Example

ts
const client = await getMsGraphClient(creds);
await copyFile(client, {
  fileId: 'original-file-id',
  driveId: 'source-drive',
  destinationFolderId: 'archive-folder',
  destinationDriveId: 'archive-drive',
  name: 'budget-backup.xlsx',
});

Matterway Assistant SDK Documentation