Skip to content

Commit 80ba46b

Browse files
Capability to pass in headers while creating upload session in large file upload
1 parent 8835e59 commit 80ba46b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/tasks/LargeFileUploadTask.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
import { Client } from "../index";
1313
import { Range } from "../Range";
1414

15+
/**
16+
* @interface
17+
* Signature to representing key value pairs
18+
* @property {[key: string] : string | number} - The Key value pair
19+
*/
20+
interface KeyValuePairObjectStringNumber {
21+
[key: string]: string | number;
22+
}
23+
1524
/**
1625
* @interface
1726
* Signature to represent the resulting response in the status enquiry request
@@ -104,11 +113,15 @@ export class LargeFileUploadTask {
104113
* Makes request to the server to create an upload session
105114
* @param {Client} client - The GraphClient instance
106115
* @param {any} payload - The payload that needs to be sent
116+
* @param {KeyValuePairObjectStringNumber} headers - The headers that needs to be sent
107117
* @returns The promise that resolves to LargeFileUploadSession
108118
*/
109-
public static async createUploadSession(client: Client, requestUrl: string, payload: any): Promise<any> {
119+
public static async createUploadSession(client: Client, requestUrl: string, payload: any, headers: KeyValuePairObjectStringNumber = {}): Promise<any> {
110120
try {
111-
const session = await client.api(requestUrl).post(payload);
121+
const session = await client
122+
.api(requestUrl)
123+
.headers(headers)
124+
.post(payload);
112125
const largeFileUploadSession: LargeFileUploadSession = {
113126
url: session.uploadUrl,
114127
expiry: new Date(session.expirationDateTime),

0 commit comments

Comments
 (0)