Skip to content

Commit de10426

Browse files
Add OneDriveLargeFileUploadTask, segregate onedrive specific code to OneDriveLargeFileUploadTask, write corresponding unit tests
1 parent 86e38c5 commit de10426

22 files changed

+575
-371
lines changed

browser-wrapper.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
// make MicrosoftGraph globally accessible
22
// MicrosoftGraph.api() can be called directly
33
window.MicrosoftGraph = require('./lib/src/index.js');
4-
window.LargeFileUploadTask = require("./lib/src/LargeFileUploadTask.js").LargeFileUploadTask;

lib/graph-js-sdk-web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/LargeFileUploadTask.d.ts

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
/**
22
* @module LargeFileUploadTask
33
*/
4-
/// <reference types="node" />
54
import { Client } from "./index";
65
import { Range } from "./Range";
76
/**
87
* @interface
9-
* Signature to define options when creating an upload task
10-
* @property {string} sessionRequestUrl - The default values for parties
11-
* @property {string} fileName - Specifies the file name of the file to upload
12-
* @property {number} [rangeSize = LargeFileUploadUtil.DEFAULT_FILE_SIZE] - Specifies the range chunk size
8+
* Signature to represent the resulting response in the status enquiry request
9+
* @property {string} expirationDateTime - The expiration of the time of the upload session
10+
* @property {string[]} nextExpectedRanges - The ranges expected in next consecutive request in the upload
11+
*/
12+
interface UploadStatusResponse {
13+
expirationDateTime: string;
14+
nextExpectedRanges: string[];
15+
}
16+
/**
17+
* @interface
18+
* Signature to define options for upload task
19+
* @property {number} [rangeSize = LargeFileUploadTask.DEFAULT_FILE_SIZE] - Specifies the range chunk size
1320
*/
14-
interface LargeFileUploadTaskOptions {
15-
sessionRequestUrl: string;
16-
fileName: string;
21+
export interface LargeFileUploadTaskOptions {
1722
rangeSize?: number;
1823
}
1924
/**
@@ -22,28 +27,18 @@ interface LargeFileUploadTaskOptions {
2227
* @property {string} url - The URL to which the file upload is made
2328
* @property {Date} expiry - The expiration of the time of the upload session
2429
*/
25-
interface LargeFileUploadSession {
30+
export interface LargeFileUploadSession {
2631
url: string;
2732
expiry: Date;
2833
}
29-
/**
30-
* @interface
31-
* Signature to represent the resulting response in the status enquiry request
32-
* @property {string} expirationDateTime - The expiration of the time of the upload session
33-
* @property {string[]} nextExpectedRanges - The ranges expected in next consecutive request in the upload
34-
*/
35-
interface UploadStatusResponse {
36-
expirationDateTime: string;
37-
nextExpectedRanges: string[];
38-
}
3934
/**
4035
* @interface
4136
* Signature to define the properties and content of the file in upload task
4237
* @property {ArrayBuffer | File} content - The actual file content
4338
* @property {string} name - Specifies the file name with extension
4439
* @property {number} size - Specifies size of the file
4540
*/
46-
interface FileObject {
41+
export interface FileObject {
4742
content: ArrayBuffer | File;
4843
name: string;
4944
size: number;
@@ -62,34 +57,18 @@ export declare class LargeFileUploadTask {
6257
uploadSession: LargeFileUploadSession;
6358
/** The next range needs to be uploaded */
6459
nextRange: Range;
60+
/**
61+
* Default value for the rangeSize
62+
*/
63+
private DEFAULT_FILE_SIZE;
6564
/**
6665
* Constructs a LargeFileUploadTask
6766
* @param {Client} client - The GraphClient instance
68-
* @param {FileObject} file - The FileObject holding file needs to be uploaded
67+
* @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded
6968
* @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done
70-
* @param {LargeFileUploadTaskOptions} options - The upload task option
69+
* @param {LargeFileUploadTaskOptions} options - The upload task options
7170
*/
7271
constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions);
73-
/**
74-
* @static
75-
* @async
76-
* Creates a LargeFileUploadTask
77-
* @param {Client} client - The GraphClient instance
78-
* @param {Blob | Buffer | File} file - File represented as Blob, File or Buffer
79-
* @param {LargeFileUploadTaskOptions} options - The options for upload task
80-
* @return The promise that will be resolves to LargeFileUploadTask instance
81-
*/
82-
static create(client: Client, file: Blob | Buffer | File, options: LargeFileUploadTaskOptions): Promise<any>;
83-
/**
84-
* @static
85-
* @async
86-
* Makes request to the server to create an upload session
87-
* @param {Client} client - The GraphClient instance
88-
* @param {string} requestUrl - The URL to create the upload session
89-
* @param {any} requestPayload - The payload to be sent with the request
90-
* @return The promise that resolves to LargeFileUploadSession
91-
*/
92-
static createUploadSession(client: Client, requestUrl: string, requestPayload: any): Promise<any>;
9372
/**
9473
* Parses given range string to the Range instance
9574
* @param {string[]} ranges - The ranges value
@@ -103,7 +82,7 @@ export declare class LargeFileUploadTask {
10382
updateTaskStatus(response: UploadStatusResponse): void;
10483
/**
10584
* Gets next range that needs to be uploaded
106-
* @return - The range instance
85+
* @return The range instance
10786
*/
10887
getNextRange(): Range;
10988
/**
@@ -144,11 +123,5 @@ export declare class LargeFileUploadTask {
144123
* @return The promise resolves to the uploaded response
145124
*/
146125
resume(): Promise<any>;
147-
/**
148-
* Commits upload session to end uploading
149-
* @param {string} requestUrl - The URL to commit the upload session
150-
* @return The promise resolves to committed response
151-
*/
152-
commit(requestUrl: string): Promise<any>;
153126
}
154127
export {};

0 commit comments

Comments
 (0)