Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/tasks/LargeFileUploadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -95,7 +95,7 @@ export class LargeFileUploadTask<T> {
* @protected
* The GraphClient instance
*/
protected client: Client;
protected client: GraphBaseClient;

/**
* @protected
Expand Down Expand Up @@ -132,11 +132,8 @@ export class LargeFileUploadTask<T> {
* @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<LargeFileUploadSession> {
const session = await client
.api(requestUrl)
.headers(headers)
.post(payload);
public static async createUploadSession(client: GraphBaseClient, requestUrl: string, payload: any, headers: KeyValuePairObjectStringNumber = {}): Promise<LargeFileUploadSession> {
const session = await client.api(requestUrl).headers(headers).post(payload);
const largeFileUploadSession: LargeFileUploadSession = {
url: session.uploadUrl,
expiry: new Date(session.expirationDateTime),
Expand All @@ -155,7 +152,7 @@ export class LargeFileUploadTask<T> {
* @param {LargeFileUploadTaskOptions} options - The upload task options
* @returns An instance of LargeFileUploadTask
*/
public constructor(client: Client, file: FileObject<T>, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions = {}) {
public constructor(client: GraphBaseClient, file: FileObject<T>, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions = {}) {
this.client = client;

if (!file.sliceFile) {
Expand Down Expand Up @@ -329,10 +326,7 @@ export class LargeFileUploadTask<T> {
* @returns The promise resolves to cancelled response
*/
public async cancel(): Promise<unknown> {
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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/OneDriveLargeFileUploadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -137,7 +137,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
* @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<OneDriveLargeFileUploadTask<Blob | ArrayBuffer | Uint8Array>> {
public static async create(client: GraphBaseClient, file: Blob | Uint8Array | File, options: OneDriveLargeFileUploadOptions): Promise<OneDriveLargeFileUploadTask<Blob | ArrayBuffer | Uint8Array>> {
if (!client || !file || !options) {
throw new GraphClientError("Please provide the Graph client instance, file object and OneDriveLargeFileUploadOptions value");
}
Expand All @@ -157,7 +157,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
* @param {OneDriveLargeFileUploadOptions} options - The options for upload task
* @returns The promise that will be resolves to OneDriveLargeFileUploadTask instance
*/
public static async createTaskWithFileObject<T>(client: Client, fileObject: FileObject<T>, options: OneDriveLargeFileUploadOptions): Promise<OneDriveLargeFileUploadTask<T>> {
public static async createTaskWithFileObject<T>(client: GraphBaseClient, fileObject: FileObject<T>, options: OneDriveLargeFileUploadOptions): Promise<OneDriveLargeFileUploadTask<T>> {
if (!client || !fileObject || !options) {
throw new GraphClientError("Please provide the Graph client instance, FileObject interface implementation and OneDriveLargeFileUploadOptions value");
}
Expand Down Expand Up @@ -185,7 +185,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
* @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<LargeFileUploadSession> {
public static async createUploadSession(client: GraphBaseClient, requestUrl: string, payloadOptions: OneDriveFileUploadSessionPayLoad): Promise<LargeFileUploadSession> {
const payload = {
item: {
"@microsoft.graph.conflictBehavior": payloadOptions?.conflictBehavior || "rename",
Expand All @@ -206,7 +206,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
* @param {LargeFileUploadTaskOptions} options - The upload task options
* @returns An instance of OneDriveLargeFileUploadTask
*/
public constructor(client: Client, file: FileObject<T>, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions) {
public constructor(client: GraphBaseClient, file: FileObject<T>, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions) {
super(client, file, uploadSession, options);
}

Expand Down