UNPKG

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