UNPKG

5.14 kBTypeScriptView Raw
1/**
2 * -------------------------------------------------------------------------------------------
3 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4 * See License in the project root for license information.
5 * -------------------------------------------------------------------------------------------
6 */
7/// <reference types="node" />
8import { Client } from "../index";
9import { UploadEventHandlers } from "./FileUploadTask/Interfaces/IUploadEventHandlers";
10import { FileObject, LargeFileUploadSession, LargeFileUploadTask, LargeFileUploadTaskOptions } from "./LargeFileUploadTask";
11/**
12 * @interface
13 * Signature to define options when creating an upload task
14 * @property {string} fileName - Specifies the name of a file to be uploaded (with extension)
15 * @property {string} [path] - The path to which the file needs to be uploaded
16 * @property {number} [rangeSize] - Specifies the range chunk size
17 */
18export interface OneDriveLargeFileUploadOptions {
19 fileName: string;
20 path?: string;
21 rangeSize?: number;
22 conflictBehavior?: string;
23 uploadEventHandlers?: UploadEventHandlers;
24}
25/**
26 * @interface
27 * Signature to define options when creating an upload task
28 * @property {string} fileName - Specifies the name of a file to be uploaded (with extension)
29 * @property {string} [path] - The path to which the file needs to be uploaded
30 * @property {number} [rangeSize] - Specifies the range chunk size
31 */
32interface OneDriveFileUploadSessionPayLoad {
33 fileName: string;
34 conflictBehavior?: string;
35}
36/**
37 * @class
38 * Class representing OneDriveLargeFileUploadTask
39 */
40export declare class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
41 /**
42 * @private
43 * @static
44 * Default path for the file being uploaded
45 */
46 private static DEFAULT_UPLOAD_PATH;
47 /**
48 * @private
49 * @static
50 * Constructs the create session url for Onedrive
51 * @param {string} fileName - The name of the file
52 * @param {path} [path = OneDriveLargeFileUploadTask.DEFAULT_UPLOAD_PATH] - The path for the upload
53 * @returns The constructed create session url
54 */
55 private static constructCreateSessionUrl;
56 /**
57 * @public
58 * @static
59 * @async
60 * Creates a OneDriveLargeFileUploadTask
61 * @param {Client} client - The GraphClient instance
62 * @param {Blob | Buffer | File} file - File represented as Blob, Buffer or File
63 * @param {OneDriveLargeFileUploadOptions} options - The options for upload task
64 * @returns The promise that will be resolves to OneDriveLargeFileUploadTask instance
65 */
66 static create(client: Client, file: Blob | Buffer | File, options: OneDriveLargeFileUploadOptions): Promise<OneDriveLargeFileUploadTask<Blob | ArrayBuffer | Buffer>>;
67 /**
68 * @public
69 * @static
70 * @async
71 * Creates a OneDriveLargeFileUploadTask
72 * @param {Client} client - The GraphClient instance
73 * @param {FileObject} file - FileObject instance
74 * @param {OneDriveLargeFileUploadOptions} options - The options for upload task
75 * @returns The promise that will be resolves to OneDriveLargeFileUploadTask instance
76 */
77 static createTaskWithFileObject<T>(client: Client, fileObject: FileObject<T>, options: OneDriveLargeFileUploadOptions): Promise<OneDriveLargeFileUploadTask<T>>;
78 /**
79 * @public
80 * @static
81 * @async
82 * Makes request to the server to create an upload session
83 * @param {Client} client - The GraphClient instance
84 * @param {string} requestUrl - The URL to create the upload session
85 * @param {string} fileName - The name of a file to upload, (with extension)
86 * @param {string} conflictBehavior - Conflict behaviour option. Default is 'rename'
87 * @returns The promise that resolves to LargeFileUploadSession
88 */
89 static createUploadSession(client: Client, requestUrl: string, payloadOptions: OneDriveFileUploadSessionPayLoad): Promise<LargeFileUploadSession>;
90 /**
91 * @public
92 * @constructor
93 * Constructs a OneDriveLargeFileUploadTask
94 * @param {Client} client - The GraphClient instance
95 * @param {FileObject} file - The FileObject holding details of a file that needs to be uploaded
96 * @param {LargeFileUploadSession} uploadSession - The upload session to which the upload has to be done
97 * @param {LargeFileUploadTaskOptions} options - The upload task options
98 * @returns An instance of OneDriveLargeFileUploadTask
99 */
100 constructor(client: Client, file: FileObject<T>, uploadSession: LargeFileUploadSession, options: LargeFileUploadTaskOptions);
101 /**
102 * @public
103 * Commits upload session to end uploading
104 * @param {string} requestUrl - The URL to commit the upload session
105 * @param {string} conflictBehavior - Conflict behaviour option. Default is 'rename'
106 * @returns The promise resolves to committed response
107 */
108 commit(requestUrl: string, conflictBehavior?: string): Promise<unknown>;
109}
110export {};