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
2 changes: 2 additions & 0 deletions samples/typescript/tasks/OneDriveLargeFileUploadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { client } from "../clientInitialization/ClientWithOptions";
async function upload() {
const file = fs.createReadStream("./test.pdf");
const fileName = "FILENAME";
const fileDescription = "FILEDESCRIPTION";
const stats = fs.statSync(`./test.pdf`);
const totalSize = stats.size;

Expand All @@ -38,6 +39,7 @@ async function upload() {

const options: OneDriveLargeFileUploadOptions = {
fileName,
fileDescription,
conflictBehavior: "rename",
rangeSize: 1024 * 1024,
uploadEventHandlers,
Expand Down
6 changes: 6 additions & 0 deletions src/tasks/OneDriveLargeFileUploadTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import { getValidRangeSize } from "./OneDriveLargeFileUploadTaskUtil";
* @interface
* Signature to define options when creating an upload task
* @property {string} fileName - Specifies the name of a file to be uploaded (with extension)
* @property {string} [fileDescription] - Specifies the description of the file to be uploaded
* @property {string} [path] - The path to which the file needs to be uploaded
* @property {number} [rangeSize] - Specifies the range chunk size
* @property {string} [conflictBehavior] - Conflict behaviour option
* @property {UploadEventHandlers} [uploadEventHandlers] - UploadEventHandlers attached to an upload task
*/
export interface OneDriveLargeFileUploadOptions {
fileName: string;
fileDescription?: string;
path?: string;
rangeSize?: number;
conflictBehavior?: string;
Expand All @@ -37,10 +39,12 @@ export interface OneDriveLargeFileUploadOptions {
* @interface
* Signature to define options when creating an upload task
* @property {string} fileName - Specifies the name of a file to be uploaded (with extension)
* @property {string} [fileDescription] - Specifies the description of the file to be uploaded
* @property {string} [conflictBehavior] - Conflict behaviour option
*/
interface OneDriveFileUploadSessionPayLoad {
fileName: string;
fileDescription?: string;
conflictBehavior?: string;
}

Expand Down Expand Up @@ -160,6 +164,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
const requestUrl = OneDriveLargeFileUploadTask.constructCreateSessionUrl(options.fileName, options.path);
const uploadSessionPayload: OneDriveFileUploadSessionPayLoad = {
fileName: options.fileName,
fileDescription: options.fileDescription,
conflictBehavior: options.conflictBehavior,
};
const session = await OneDriveLargeFileUploadTask.createUploadSession(client, requestUrl, uploadSessionPayload);
Expand All @@ -185,6 +190,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
item: {
"@microsoft.graph.conflictBehavior": payloadOptions?.conflictBehavior || "rename",
name: payloadOptions?.fileName,
description: payloadOptions?.fileDescription,
},
};
return super.createUploadSession(client, requestUrl, payload);
Expand Down