microsoft-graph 3.9.2 → 3.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/operations/driveItem/createDriveItemContent.d.ts +3 -3
- package/dist/cjs/operations/driveItem/createDriveItemContent.d.ts.map +1 -1
- package/dist/cjs/operations/driveItem/createDriveItemContent.js +38 -30
- package/dist/cjs/services/http.js +13 -8
- package/dist/esm/operations/driveItem/createDriveItemContent.d.ts +3 -3
- package/dist/esm/operations/driveItem/createDriveItemContent.d.ts.map +1 -1
- package/dist/esm/operations/driveItem/createDriveItemContent.js +38 -30
- package/dist/esm/services/http.js +13 -8
- package/docs/api/createDriveItemContent.md +10 -12
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ export declare const chunkSizeMultiple: number;
|
|
|
20
20
|
*/
|
|
21
21
|
export interface CreateDriveItemContentOptions {
|
|
22
22
|
conflictBehavior?: "fail" | "replace" | "rename";
|
|
23
|
-
|
|
23
|
+
maxChunkSize?: number;
|
|
24
24
|
progress?: (bytes: number) => void;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -31,8 +31,8 @@ export interface CreateDriveItemContentOptions {
|
|
|
31
31
|
* @param contentLength The total size in bytes of the content to be uploaded.
|
|
32
32
|
* @param options Optional. Additional options for the upload operation.
|
|
33
33
|
* @param options.conflictBehavior Optional. Specifies how to handle conflicts if the file already exists. Default is 'fail'.
|
|
34
|
-
* @param options.
|
|
35
|
-
* @param options.progress Optional. A callback function that is called
|
|
34
|
+
* @param options.maxChunkSize Optional. The size of each chunk to be uploaded in bytes. Default is 10MB.
|
|
35
|
+
* @param options.progress Optional. A callback function that is called with the number of bytes uploaded after each chunk.
|
|
36
36
|
* @returns The newly created drive item.
|
|
37
37
|
* @see https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
38
38
|
* @see https://learn.microsoft.com/en-us/graph/api/resources/uploadsession
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDriveItemContent.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/createDriveItemContent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"createDriveItemContent.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/createDriveItemContent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM1F;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAa,CAAC;AAc5C;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B;IAC7C,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAA8B,sBAAsB,CAAC,SAAS,EAAE,QAAQ,GAAG,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAE,6BAAkC,GAAG,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC,CAmG7P"}
|
|
@@ -10,6 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.chunkSizeMultiple = void 0;
|
|
12
12
|
exports.default = createDriveItemContent;
|
|
13
|
+
const path_1 = require("path");
|
|
13
14
|
const InvalidArgumentError_ts_1 = __importDefault(require("../../errors/InvalidArgumentError.js"));
|
|
14
15
|
const ProtocolError_ts_1 = __importDefault(require("../../errors/ProtocolError.js"));
|
|
15
16
|
const driveItem_ts_1 = require("../../services/driveItem.js");
|
|
@@ -22,7 +23,7 @@ const templatedPaths_ts_1 = require("../../services/templatedPaths.js");
|
|
|
22
23
|
* @see https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
23
24
|
*/
|
|
24
25
|
exports.chunkSizeMultiple = 320 * 1024;
|
|
25
|
-
const
|
|
26
|
+
const defaultMaxChunkSize = exports.chunkSizeMultiple * 32;
|
|
26
27
|
/**
|
|
27
28
|
* Creates a new drive item in the specified parent drive or folder using a stream as content.
|
|
28
29
|
* @param parentRef Reference to the parent drive or folder where the drive item will be created.
|
|
@@ -31,21 +32,21 @@ const defaultChunkSize = exports.chunkSizeMultiple * 32;
|
|
|
31
32
|
* @param contentLength The total size in bytes of the content to be uploaded.
|
|
32
33
|
* @param options Optional. Additional options for the upload operation.
|
|
33
34
|
* @param options.conflictBehavior Optional. Specifies how to handle conflicts if the file already exists. Default is 'fail'.
|
|
34
|
-
* @param options.
|
|
35
|
-
* @param options.progress Optional. A callback function that is called
|
|
35
|
+
* @param options.maxChunkSize Optional. The size of each chunk to be uploaded in bytes. Default is 10MB.
|
|
36
|
+
* @param options.progress Optional. A callback function that is called with the number of bytes uploaded after each chunk.
|
|
36
37
|
* @returns The newly created drive item.
|
|
37
38
|
* @see https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
38
39
|
* @see https://learn.microsoft.com/en-us/graph/api/resources/uploadsession
|
|
39
40
|
*/
|
|
40
41
|
async function createDriveItemContent(parentRef, itemPath, contentStream, contentLength, options = {}) {
|
|
41
|
-
const { conflictBehavior = "fail",
|
|
42
|
-
if (
|
|
43
|
-
throw new InvalidArgumentError_ts_1.default(`Chunk size (${
|
|
42
|
+
const { conflictBehavior = "fail", maxChunkSize = defaultMaxChunkSize, progress = () => { } } = options;
|
|
43
|
+
if (maxChunkSize % exports.chunkSizeMultiple !== 0) {
|
|
44
|
+
throw new InvalidArgumentError_ts_1.default(`Chunk size (${maxChunkSize.toLocaleString()}) must be a multiple of ${(exports.chunkSizeMultiple / 1024).toLocaleString()} KiB *${exports.chunkSizeMultiple.toLocaleString()} bytes).`);
|
|
44
45
|
}
|
|
45
46
|
const pathSegment = parentRef.itemId ? "items/{item-id}" : "root";
|
|
46
47
|
const uploadSessionUrl = `${operationInvoker_ts_1.endpoint}${(0, templatedPaths_ts_1.generatePath)(`/sites/{site-id}/drives/{drive-id}/${pathSegment}:/${itemPath}:/createUploadSession`, parentRef)}`;
|
|
47
48
|
const accessToken = await parentRef.context.generateAccessToken();
|
|
48
|
-
const fileName =
|
|
49
|
+
const fileName = (0, path_1.basename)(itemPath);
|
|
49
50
|
const { uploadUrl } = await (0, http_ts_1.execute)({
|
|
50
51
|
url: uploadSessionUrl,
|
|
51
52
|
method: "POST",
|
|
@@ -65,26 +66,46 @@ async function createDriveItemContent(parentRef, itemPath, contentStream, conten
|
|
|
65
66
|
if (!reader) {
|
|
66
67
|
throw new InvalidArgumentError_ts_1.default("contentStream is not an async iterable");
|
|
67
68
|
}
|
|
68
|
-
const buffer = Buffer.alloc(chunkSize);
|
|
69
69
|
let contentPosition = 0;
|
|
70
70
|
let item = null;
|
|
71
|
+
let leftover = null;
|
|
71
72
|
while (contentPosition < contentLength) {
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
const chunkSize = Math.min(maxChunkSize, contentLength - contentPosition);
|
|
74
|
+
const buffer = Buffer.alloc(chunkSize);
|
|
75
|
+
let length = 0;
|
|
76
|
+
while (length < chunkSize) {
|
|
77
|
+
let c = null;
|
|
78
|
+
if (leftover) {
|
|
79
|
+
c = leftover;
|
|
80
|
+
leftover = null;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const { value, done } = await reader.next();
|
|
84
|
+
if (done)
|
|
85
|
+
break;
|
|
86
|
+
c = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
87
|
+
}
|
|
88
|
+
const toCopy = Math.min(c.length, chunkSize - length);
|
|
89
|
+
c.copy(buffer, length, 0, toCopy);
|
|
90
|
+
length += toCopy;
|
|
91
|
+
if (toCopy < c.length) {
|
|
92
|
+
leftover = c.subarray(toCopy);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const chunkStart = contentPosition;
|
|
96
|
+
const chunkEnd = contentPosition + length - 1;
|
|
97
|
+
const chunk = buffer.subarray(0, length);
|
|
77
98
|
const response = await (0, http_ts_1.execute)({
|
|
78
99
|
url: uploadUrl,
|
|
79
100
|
method: "PUT",
|
|
80
101
|
headers: {
|
|
81
|
-
"Content-Length":
|
|
82
|
-
"Content-Range":
|
|
102
|
+
"Content-Length": `${length}`,
|
|
103
|
+
"Content-Range": `bytes ${chunkStart}-${chunkEnd}/${contentLength}`,
|
|
83
104
|
},
|
|
84
|
-
data:
|
|
105
|
+
data: chunk,
|
|
85
106
|
responseType: "json",
|
|
86
107
|
});
|
|
87
|
-
contentPosition +=
|
|
108
|
+
contentPosition += length;
|
|
88
109
|
progress(contentPosition);
|
|
89
110
|
if (isDriveItem(response)) {
|
|
90
111
|
item = response;
|
|
@@ -103,16 +124,3 @@ async function createDriveItemContent(parentRef, itemPath, contentStream, conten
|
|
|
103
124
|
return typeof obj === "object" && obj !== null && "id" in obj;
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
|
-
async function read(chunkSize, contentPosition, contentLength, reader, buffer) {
|
|
107
|
-
let length = 0;
|
|
108
|
-
while (length < chunkSize && contentPosition + length < contentLength) {
|
|
109
|
-
const { value, done } = await reader.next();
|
|
110
|
-
if (done)
|
|
111
|
-
break;
|
|
112
|
-
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
113
|
-
const toCopy = Math.min(chunk.length, chunkSize - length, contentLength - contentPosition - length);
|
|
114
|
-
chunk.copy(buffer, length, 0, toCopy);
|
|
115
|
-
length += toCopy;
|
|
116
|
-
}
|
|
117
|
-
return length;
|
|
118
|
-
}
|
|
@@ -201,14 +201,19 @@ function waitToString(milliseconds) {
|
|
|
201
201
|
function errorObjectToString(obj) {
|
|
202
202
|
const maxLength = 1024;
|
|
203
203
|
const ellipses = "...";
|
|
204
|
-
|
|
205
|
-
.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
try {
|
|
205
|
+
let str = JSON.stringify(obj, null, 2)
|
|
206
|
+
.split("\n")
|
|
207
|
+
.map((line) => ` ${line}`)
|
|
208
|
+
.join("\n");
|
|
209
|
+
if (str.length > maxLength) {
|
|
210
|
+
str = `${str.substring(0, maxLength - ellipses.length)}${ellipses}`;
|
|
211
|
+
}
|
|
212
|
+
return `${str}\n`;
|
|
213
|
+
}
|
|
214
|
+
catch (_) {
|
|
215
|
+
return "<not displayable>\n";
|
|
216
|
+
}
|
|
212
217
|
}
|
|
213
218
|
function handleResponseError(response, errorLog, attempts, operationIndex = null) {
|
|
214
219
|
const error = response.data;
|
|
@@ -20,7 +20,7 @@ export declare const chunkSizeMultiple: number;
|
|
|
20
20
|
*/
|
|
21
21
|
export interface CreateDriveItemContentOptions {
|
|
22
22
|
conflictBehavior?: "fail" | "replace" | "rename";
|
|
23
|
-
|
|
23
|
+
maxChunkSize?: number;
|
|
24
24
|
progress?: (bytes: number) => void;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -31,8 +31,8 @@ export interface CreateDriveItemContentOptions {
|
|
|
31
31
|
* @param contentLength The total size in bytes of the content to be uploaded.
|
|
32
32
|
* @param options Optional. Additional options for the upload operation.
|
|
33
33
|
* @param options.conflictBehavior Optional. Specifies how to handle conflicts if the file already exists. Default is 'fail'.
|
|
34
|
-
* @param options.
|
|
35
|
-
* @param options.progress Optional. A callback function that is called
|
|
34
|
+
* @param options.maxChunkSize Optional. The size of each chunk to be uploaded in bytes. Default is 10MB.
|
|
35
|
+
* @param options.progress Optional. A callback function that is called with the number of bytes uploaded after each chunk.
|
|
36
36
|
* @returns The newly created drive item.
|
|
37
37
|
* @see https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
38
38
|
* @see https://learn.microsoft.com/en-us/graph/api/resources/uploadsession
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDriveItemContent.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/createDriveItemContent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"createDriveItemContent.d.ts","sourceRoot":"","sources":["../../../../src/operations/driveItem/createDriveItemContent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM1F;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAa,CAAC;AAc5C;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B;IAC7C,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAA8B,sBAAsB,CAAC,SAAS,EAAE,QAAQ,GAAG,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAE,6BAAkC,GAAG,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC,CAmG7P"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @module createDriveItemContent
|
|
4
4
|
* @category Operations
|
|
5
5
|
*/
|
|
6
|
+
import { basename } from "path";
|
|
6
7
|
import InvalidArgumentError from "../../errors/InvalidArgumentError.js";
|
|
7
8
|
import ProtocolError from "../../errors/ProtocolError.js";
|
|
8
9
|
import { createDriveItemRef } from "../../services/driveItem.js";
|
|
@@ -15,7 +16,7 @@ import { generatePath } from "../../services/templatedPaths.js";
|
|
|
15
16
|
* @see https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
16
17
|
*/
|
|
17
18
|
export const chunkSizeMultiple = 320 * 1024;
|
|
18
|
-
const
|
|
19
|
+
const defaultMaxChunkSize = chunkSizeMultiple * 32;
|
|
19
20
|
/**
|
|
20
21
|
* Creates a new drive item in the specified parent drive or folder using a stream as content.
|
|
21
22
|
* @param parentRef Reference to the parent drive or folder where the drive item will be created.
|
|
@@ -24,21 +25,21 @@ const defaultChunkSize = chunkSizeMultiple * 32;
|
|
|
24
25
|
* @param contentLength The total size in bytes of the content to be uploaded.
|
|
25
26
|
* @param options Optional. Additional options for the upload operation.
|
|
26
27
|
* @param options.conflictBehavior Optional. Specifies how to handle conflicts if the file already exists. Default is 'fail'.
|
|
27
|
-
* @param options.
|
|
28
|
-
* @param options.progress Optional. A callback function that is called
|
|
28
|
+
* @param options.maxChunkSize Optional. The size of each chunk to be uploaded in bytes. Default is 10MB.
|
|
29
|
+
* @param options.progress Optional. A callback function that is called with the number of bytes uploaded after each chunk.
|
|
29
30
|
* @returns The newly created drive item.
|
|
30
31
|
* @see https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
31
32
|
* @see https://learn.microsoft.com/en-us/graph/api/resources/uploadsession
|
|
32
33
|
*/
|
|
33
34
|
export default async function createDriveItemContent(parentRef, itemPath, contentStream, contentLength, options = {}) {
|
|
34
|
-
const { conflictBehavior = "fail",
|
|
35
|
-
if (
|
|
36
|
-
throw new InvalidArgumentError(`Chunk size (${
|
|
35
|
+
const { conflictBehavior = "fail", maxChunkSize = defaultMaxChunkSize, progress = () => { } } = options;
|
|
36
|
+
if (maxChunkSize % chunkSizeMultiple !== 0) {
|
|
37
|
+
throw new InvalidArgumentError(`Chunk size (${maxChunkSize.toLocaleString()}) must be a multiple of ${(chunkSizeMultiple / 1024).toLocaleString()} KiB *${chunkSizeMultiple.toLocaleString()} bytes).`);
|
|
37
38
|
}
|
|
38
39
|
const pathSegment = parentRef.itemId ? "items/{item-id}" : "root";
|
|
39
40
|
const uploadSessionUrl = `${endpoint}${generatePath(`/sites/{site-id}/drives/{drive-id}/${pathSegment}:/${itemPath}:/createUploadSession`, parentRef)}`;
|
|
40
41
|
const accessToken = await parentRef.context.generateAccessToken();
|
|
41
|
-
const fileName = itemPath
|
|
42
|
+
const fileName = basename(itemPath);
|
|
42
43
|
const { uploadUrl } = await execute({
|
|
43
44
|
url: uploadSessionUrl,
|
|
44
45
|
method: "POST",
|
|
@@ -58,26 +59,46 @@ export default async function createDriveItemContent(parentRef, itemPath, conten
|
|
|
58
59
|
if (!reader) {
|
|
59
60
|
throw new InvalidArgumentError("contentStream is not an async iterable");
|
|
60
61
|
}
|
|
61
|
-
const buffer = Buffer.alloc(chunkSize);
|
|
62
62
|
let contentPosition = 0;
|
|
63
63
|
let item = null;
|
|
64
|
+
let leftover = null;
|
|
64
65
|
while (contentPosition < contentLength) {
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const chunkSize = Math.min(maxChunkSize, contentLength - contentPosition);
|
|
67
|
+
const buffer = Buffer.alloc(chunkSize);
|
|
68
|
+
let length = 0;
|
|
69
|
+
while (length < chunkSize) {
|
|
70
|
+
let c = null;
|
|
71
|
+
if (leftover) {
|
|
72
|
+
c = leftover;
|
|
73
|
+
leftover = null;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const { value, done } = await reader.next();
|
|
77
|
+
if (done)
|
|
78
|
+
break;
|
|
79
|
+
c = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
80
|
+
}
|
|
81
|
+
const toCopy = Math.min(c.length, chunkSize - length);
|
|
82
|
+
c.copy(buffer, length, 0, toCopy);
|
|
83
|
+
length += toCopy;
|
|
84
|
+
if (toCopy < c.length) {
|
|
85
|
+
leftover = c.subarray(toCopy);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const chunkStart = contentPosition;
|
|
89
|
+
const chunkEnd = contentPosition + length - 1;
|
|
90
|
+
const chunk = buffer.subarray(0, length);
|
|
70
91
|
const response = await execute({
|
|
71
92
|
url: uploadUrl,
|
|
72
93
|
method: "PUT",
|
|
73
94
|
headers: {
|
|
74
|
-
"Content-Length":
|
|
75
|
-
"Content-Range":
|
|
95
|
+
"Content-Length": `${length}`,
|
|
96
|
+
"Content-Range": `bytes ${chunkStart}-${chunkEnd}/${contentLength}`,
|
|
76
97
|
},
|
|
77
|
-
data:
|
|
98
|
+
data: chunk,
|
|
78
99
|
responseType: "json",
|
|
79
100
|
});
|
|
80
|
-
contentPosition +=
|
|
101
|
+
contentPosition += length;
|
|
81
102
|
progress(contentPosition);
|
|
82
103
|
if (isDriveItem(response)) {
|
|
83
104
|
item = response;
|
|
@@ -96,16 +117,3 @@ export default async function createDriveItemContent(parentRef, itemPath, conten
|
|
|
96
117
|
return typeof obj === "object" && obj !== null && "id" in obj;
|
|
97
118
|
}
|
|
98
119
|
}
|
|
99
|
-
async function read(chunkSize, contentPosition, contentLength, reader, buffer) {
|
|
100
|
-
let length = 0;
|
|
101
|
-
while (length < chunkSize && contentPosition + length < contentLength) {
|
|
102
|
-
const { value, done } = await reader.next();
|
|
103
|
-
if (done)
|
|
104
|
-
break;
|
|
105
|
-
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
106
|
-
const toCopy = Math.min(chunk.length, chunkSize - length, contentLength - contentPosition - length);
|
|
107
|
-
chunk.copy(buffer, length, 0, toCopy);
|
|
108
|
-
length += toCopy;
|
|
109
|
-
}
|
|
110
|
-
return length;
|
|
111
|
-
}
|
|
@@ -193,14 +193,19 @@ function waitToString(milliseconds) {
|
|
|
193
193
|
function errorObjectToString(obj) {
|
|
194
194
|
const maxLength = 1024;
|
|
195
195
|
const ellipses = "...";
|
|
196
|
-
|
|
197
|
-
.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
try {
|
|
197
|
+
let str = JSON.stringify(obj, null, 2)
|
|
198
|
+
.split("\n")
|
|
199
|
+
.map((line) => ` ${line}`)
|
|
200
|
+
.join("\n");
|
|
201
|
+
if (str.length > maxLength) {
|
|
202
|
+
str = `${str.substring(0, maxLength - ellipses.length)}${ellipses}`;
|
|
203
|
+
}
|
|
204
|
+
return `${str}\n`;
|
|
205
|
+
}
|
|
206
|
+
catch (_) {
|
|
207
|
+
return "<not displayable>\n";
|
|
208
|
+
}
|
|
204
209
|
}
|
|
205
210
|
function handleResponseError(response, errorLog, attempts, operationIndex = null) {
|
|
206
211
|
const error = response.data;
|
|
@@ -8,33 +8,31 @@ Creates a new drive item in the specified parent drive or folder using a stream
|
|
|
8
8
|
|
|
9
9
|
### CreateDriveItemContentOptions
|
|
10
10
|
|
|
11
|
-
Defined in: [src/operations/driveItem/createDriveItemContent.ts:
|
|
11
|
+
Defined in: [src/operations/driveItem/createDriveItemContent.ts:43](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/operations/driveItem/createDriveItemContent.ts#L43)
|
|
12
12
|
|
|
13
13
|
Options for creating a drive item with content upload.
|
|
14
14
|
|
|
15
15
|
#### Properties
|
|
16
16
|
|
|
17
|
-
#####
|
|
17
|
+
##### conflictBehavior?
|
|
18
18
|
|
|
19
|
-
> `optional` **
|
|
19
|
+
> `optional` **conflictBehavior**: `"replace"` \| `"fail"` \| `"rename"`
|
|
20
20
|
|
|
21
21
|
Defined in: [src/operations/driveItem/createDriveItemContent.ts:44](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/operations/driveItem/createDriveItemContent.ts#L44)
|
|
22
22
|
|
|
23
|
-
Optional.
|
|
23
|
+
Optional. Specifies how to handle conflicts if the file already exists. Can be 'fail', 'replace', or 'rename'.
|
|
24
24
|
|
|
25
|
-
#####
|
|
25
|
+
##### maxChunkSize?
|
|
26
26
|
|
|
27
|
-
> `optional` **
|
|
27
|
+
> `optional` **maxChunkSize**: `number`
|
|
28
28
|
|
|
29
|
-
Defined in: [src/operations/driveItem/createDriveItemContent.ts:
|
|
30
|
-
|
|
31
|
-
Optional. Specifies how to handle conflicts if the file already exists. Can be 'fail', 'replace', or 'rename'.
|
|
29
|
+
Defined in: [src/operations/driveItem/createDriveItemContent.ts:45](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/operations/driveItem/createDriveItemContent.ts#L45)
|
|
32
30
|
|
|
33
31
|
##### progress()?
|
|
34
32
|
|
|
35
33
|
> `optional` **progress**: (`bytes`) => `void`
|
|
36
34
|
|
|
37
|
-
Defined in: [src/operations/driveItem/createDriveItemContent.ts:
|
|
35
|
+
Defined in: [src/operations/driveItem/createDriveItemContent.ts:46](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/operations/driveItem/createDriveItemContent.ts#L46)
|
|
38
36
|
|
|
39
37
|
Optional. Callback function called with the number of bytes uploaded after each chunk.
|
|
40
38
|
|
|
@@ -54,7 +52,7 @@ Optional. Callback function called with the number of bytes uploaded after each
|
|
|
54
52
|
|
|
55
53
|
> `const` **chunkSizeMultiple**: `number`
|
|
56
54
|
|
|
57
|
-
Defined in: [src/operations/driveItem/createDriveItemContent.ts:
|
|
55
|
+
Defined in: [src/operations/driveItem/createDriveItemContent.ts:23](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/operations/driveItem/createDriveItemContent.ts#L23)
|
|
58
56
|
|
|
59
57
|
The required chunk size multiple for upload sessions.
|
|
60
58
|
|
|
@@ -72,7 +70,7 @@ https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession
|
|
|
72
70
|
|
|
73
71
|
> **createDriveItemContent**(`parentRef`, `itemPath`, `contentStream`, `contentLength`, `options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`DriveItem` & [`SiteRef`](Site-1.md#siteref) & `object` & `object`\>
|
|
74
72
|
|
|
75
|
-
Defined in: [src/operations/driveItem/createDriveItemContent.ts:
|
|
73
|
+
Defined in: [src/operations/driveItem/createDriveItemContent.ts:63](https://github.com/Future-Secure-AI/microsoft-graph/blob/main/src/operations/driveItem/createDriveItemContent.ts#L63)
|
|
76
74
|
|
|
77
75
|
Creates a new drive item in the specified parent drive or folder using a stream as content.
|
|
78
76
|
|