-
Notifications
You must be signed in to change notification settings - Fork 547
/
Copy pathcreateOdspCreateContainerRequest.ts
42 lines (39 loc) · 1.47 KB
/
createOdspCreateContainerRequest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
import { IRequest } from "@fluidframework/core-interfaces";
import { DriverHeader } from "@fluidframework/driver-definitions/internal";
import { ISharingLinkKind } from "@fluidframework/odsp-driver-definitions/internal";
import { buildOdspShareLinkReqParams } from "./odspUtils.js";
/**
* Create the request object with url and headers for creating a new file on OneDrive Sharepoint
* @param siteUrl - Base url for OneDrive
* @param driveId - drive identifier
* @param filePath - path where file needs to be created
* @param fileName - name of the new file to be created
* @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
* will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
* @legacy
* @alpha
*/
export function createOdspCreateContainerRequest(
siteUrl: string,
driveId: string,
filePath: string,
fileName: string,
createShareLinkType?: ISharingLinkKind,
): IRequest {
const shareLinkRequestParams = buildOdspShareLinkReqParams(createShareLinkType);
const createNewRequest: IRequest = {
url: `${siteUrl}?driveId=${encodeURIComponent(driveId)}&path=${encodeURIComponent(
filePath,
)}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : ""}`,
headers: {
[DriverHeader.createNew]: {
fileName,
},
},
};
return createNewRequest;
}