Skip to content

Commit f1fda65

Browse files
authored
Support 'file description' in LargeFileUploadTask. (#533)
1 parent 5183690 commit f1fda65

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

samples/typescript/tasks/OneDriveLargeFileUploadTask.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { client } from "../clientInitialization/ClientWithOptions";
2222
async function upload() {
2323
const file = fs.createReadStream("./test.pdf");
2424
const fileName = "FILENAME";
25+
const fileDescription = "FILEDESCRIPTION";
2526
const stats = fs.statSync(`./test.pdf`);
2627
const totalSize = stats.size;
2728

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

3940
const options: OneDriveLargeFileUploadOptions = {
4041
fileName,
42+
fileDescription,
4143
conflictBehavior: "rename",
4244
rangeSize: 1024 * 1024,
4345
uploadEventHandlers,

src/tasks/OneDriveLargeFileUploadTask.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ import { getValidRangeSize } from "./OneDriveLargeFileUploadTaskUtil";
2020
* @interface
2121
* Signature to define options when creating an upload task
2222
* @property {string} fileName - Specifies the name of a file to be uploaded (with extension)
23+
* @property {string} [fileDescription] - Specifies the description of the file to be uploaded
2324
* @property {string} [path] - The path to which the file needs to be uploaded
2425
* @property {number} [rangeSize] - Specifies the range chunk size
2526
* @property {string} [conflictBehavior] - Conflict behaviour option
2627
* @property {UploadEventHandlers} [uploadEventHandlers] - UploadEventHandlers attached to an upload task
2728
*/
2829
export interface OneDriveLargeFileUploadOptions {
2930
fileName: string;
31+
fileDescription?: string;
3032
path?: string;
3133
rangeSize?: number;
3234
conflictBehavior?: string;
@@ -37,10 +39,12 @@ export interface OneDriveLargeFileUploadOptions {
3739
* @interface
3840
* Signature to define options when creating an upload task
3941
* @property {string} fileName - Specifies the name of a file to be uploaded (with extension)
42+
* @property {string} [fileDescription] - Specifies the description of the file to be uploaded
4043
* @property {string} [conflictBehavior] - Conflict behaviour option
4144
*/
4245
interface OneDriveFileUploadSessionPayLoad {
4346
fileName: string;
47+
fileDescription?: string;
4448
conflictBehavior?: string;
4549
}
4650

@@ -160,6 +164,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
160164
const requestUrl = OneDriveLargeFileUploadTask.constructCreateSessionUrl(options.fileName, options.path);
161165
const uploadSessionPayload: OneDriveFileUploadSessionPayLoad = {
162166
fileName: options.fileName,
167+
fileDescription: options.fileDescription,
163168
conflictBehavior: options.conflictBehavior,
164169
};
165170
const session = await OneDriveLargeFileUploadTask.createUploadSession(client, requestUrl, uploadSessionPayload);
@@ -185,6 +190,7 @@ export class OneDriveLargeFileUploadTask<T> extends LargeFileUploadTask<T> {
185190
item: {
186191
"@microsoft.graph.conflictBehavior": payloadOptions?.conflictBehavior || "rename",
187192
name: payloadOptions?.fileName,
193+
description: payloadOptions?.fileDescription,
188194
},
189195
};
190196
return super.createUploadSession(client, requestUrl, payload);

0 commit comments

Comments
 (0)