Skip to content

Commit e6eb090

Browse files
Support upload from node and write unit tests
1 parent 632ba6b commit e6eb090

File tree

7 files changed

+335
-47
lines changed

7 files changed

+335
-47
lines changed

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="node" />
12
import { Client } from "./index";
23
import { Range } from "./Range";
34
interface LargeFileUploadTaskOptions {
@@ -9,21 +10,35 @@ interface LargeFileUploadSession {
910
url: string;
1011
expiry: Date;
1112
}
13+
interface UploadStatusResponse {
14+
expirationDateTime: string;
15+
nextExpectedRanges: string[];
16+
}
17+
interface NodeFile {
18+
name?: string;
19+
buffer: Buffer;
20+
}
21+
interface FileObject {
22+
content: File | ArrayBuffer;
23+
name: string;
24+
size: number;
25+
}
1226
export declare class LargeFileUploadTask {
1327
client: Client;
14-
file: File;
28+
file: FileObject;
1529
options: LargeFileUploadTaskOptions;
1630
uploadSession: LargeFileUploadSession;
1731
nextRange: Range;
18-
constructor(client: Client, file: File, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions);
19-
static create(client: Client, file: File | Blob, options: LargeFileUploadTaskOptions): Promise<any>;
32+
constructor(client: Client, file: FileObject, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions);
33+
static create(client: Client, file: Blob | File | NodeFile, options: LargeFileUploadTaskOptions): Promise<any>;
2034
static createUploadSession(client: Client, requestUrl: string, requestPayload: any): Promise<any>;
21-
private parseRange;
22-
private updateTaskStatus;
35+
static getRandomFileName(): string;
36+
parseRange(ranges: string[]): Range;
37+
updateTaskStatus(response: UploadStatusResponse): void;
2338
getNextRange(): Range;
24-
sliceFile(range: Range): Blob;
39+
sliceFile(range: Range): ArrayBuffer | Blob;
2540
upload(): Promise<any>;
26-
uploadSlice(fileSlice: Blob | File, range: Range, totalSize: number): Promise<any>;
41+
uploadSlice(fileSlice: ArrayBuffer | Blob | File, range: Range, totalSize: number): Promise<any>;
2742
cancel(): Promise<any>;
2843
getStatus(): Promise<any>;
2944
resume(): Promise<any>;

lib/src/LargeFileUploadTask.js

Lines changed: 31 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/LargeFileUploadTask.js.map

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

0 commit comments

Comments
 (0)