diff --git a/src/tasks/LargeFileUploadTask.ts b/src/tasks/LargeFileUploadTask.ts index 31bd4229a..856a0eb99 100644 --- a/src/tasks/LargeFileUploadTask.ts +++ b/src/tasks/LargeFileUploadTask.ts @@ -11,7 +11,7 @@ import { GraphClientError } from "../GraphClientError"; import { GraphResponseHandler } from "../GraphResponseHandler"; -import { Client } from "../index"; +import { GraphBaseClient } from "../index"; import { ResponseType } from "../ResponseType"; import { UploadEventHandlers } from "./FileUploadTask/Interfaces/IUploadEventHandlers"; import { Range } from "./FileUploadTask/Range"; @@ -95,7 +95,7 @@ export class LargeFileUploadTask { * @protected * The GraphClient instance */ - protected client: Client; + protected client: GraphBaseClient; /** * @protected @@ -132,11 +132,8 @@ export class LargeFileUploadTask { * @param {KeyValuePairObjectStringNumber} headers - The headers that needs to be sent * @returns The promise that resolves to LargeFileUploadSession */ - public static async createUploadSession(client: Client, requestUrl: string, payload: any, headers: KeyValuePairObjectStringNumber = {}): Promise { - const session = await client - .api(requestUrl) - .headers(headers) - .post(payload); + public static async createUploadSession(client: GraphBaseClient, requestUrl: string, payload: any, headers: KeyValuePairObjectStringNumber = {}): Promise { + const session = await client.api(requestUrl).headers(headers).post(payload); const largeFileUploadSession: LargeFileUploadSession = { url: session.uploadUrl, expiry: new Date(session.expirationDateTime), @@ -155,7 +152,7 @@ export class LargeFileUploadTask { * @param {LargeFileUploadTaskOptions} options - The upload task options * @returns An instance of LargeFileUploadTask */ - public constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions = {}) { + public constructor(client: GraphBaseClient, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions = {}) { this.client = client; if (!file.sliceFile) { @@ -329,10 +326,7 @@ export class LargeFileUploadTask { * @returns The promise resolves to cancelled response */ public async cancel(): Promise { - const cancelResponse = await this.client - .api(this.uploadSession.url) - .responseType(ResponseType.RAW) - .delete(); + const cancelResponse = await this.client.api(this.uploadSession.url).responseType(ResponseType.RAW).delete(); if (cancelResponse.status === 204) { this.uploadSession.isCancelled = true; } diff --git a/src/tasks/OneDriveLargeFileUploadTask.ts b/src/tasks/OneDriveLargeFileUploadTask.ts index 04d8072ae..eff439ea7 100644 --- a/src/tasks/OneDriveLargeFileUploadTask.ts +++ b/src/tasks/OneDriveLargeFileUploadTask.ts @@ -10,7 +10,7 @@ */ import { GraphClientError } from "../GraphClientError"; -import { Client } from "../index"; +import { GraphBaseClient } from "../index"; import { FileUpload } from "./FileUploadTask/FileObjectClasses/FileUpload"; import { UploadEventHandlers } from "./FileUploadTask/Interfaces/IUploadEventHandlers"; import { FileObject, LargeFileUploadSession, LargeFileUploadTask, LargeFileUploadTaskOptions } from "./LargeFileUploadTask"; @@ -137,7 +137,7 @@ export class OneDriveLargeFileUploadTask extends LargeFileUploadTask { * @param {OneDriveLargeFileUploadOptions} options - The options for upload task * @returns The promise that will be resolves to OneDriveLargeFileUploadTask instance */ - public static async create(client: Client, file: Blob | Uint8Array | File, options: OneDriveLargeFileUploadOptions): Promise> { + public static async create(client: GraphBaseClient, file: Blob | Uint8Array | File, options: OneDriveLargeFileUploadOptions): Promise> { if (!client || !file || !options) { throw new GraphClientError("Please provide the Graph client instance, file object and OneDriveLargeFileUploadOptions value"); } @@ -157,7 +157,7 @@ export class OneDriveLargeFileUploadTask extends LargeFileUploadTask { * @param {OneDriveLargeFileUploadOptions} options - The options for upload task * @returns The promise that will be resolves to OneDriveLargeFileUploadTask instance */ - public static async createTaskWithFileObject(client: Client, fileObject: FileObject, options: OneDriveLargeFileUploadOptions): Promise> { + public static async createTaskWithFileObject(client: GraphBaseClient, fileObject: FileObject, options: OneDriveLargeFileUploadOptions): Promise> { if (!client || !fileObject || !options) { throw new GraphClientError("Please provide the Graph client instance, FileObject interface implementation and OneDriveLargeFileUploadOptions value"); } @@ -185,7 +185,7 @@ export class OneDriveLargeFileUploadTask extends LargeFileUploadTask { * @param {string} payloadOptions - The payload option. Default conflictBehavior is 'rename' * @returns The promise that resolves to LargeFileUploadSession */ - public static async createUploadSession(client: Client, requestUrl: string, payloadOptions: OneDriveFileUploadSessionPayLoad): Promise { + public static async createUploadSession(client: GraphBaseClient, requestUrl: string, payloadOptions: OneDriveFileUploadSessionPayLoad): Promise { const payload = { item: { "@microsoft.graph.conflictBehavior": payloadOptions?.conflictBehavior || "rename", @@ -206,7 +206,7 @@ export class OneDriveLargeFileUploadTask extends LargeFileUploadTask { * @param {LargeFileUploadTaskOptions} options - The upload task options * @returns An instance of OneDriveLargeFileUploadTask */ - public constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions) { + public constructor(client: GraphBaseClient, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions) { super(client, file, uploadSession, options); }