Skip to content

Commit b2c0f86

Browse files
Updated docs for large fil upload task
1 parent 5fafad8 commit b2c0f86

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Diff for: docs/tasks/LargeFileUploadTask.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@ Get files from the input element and start uploading.
2020
async function fileUpload(elem) {
2121
let file = elem.files[0];
2222
try {
23-
let response = await largeFilUpload(client, file, file.name);
23+
let response = await largeFileUpload(client, file, file.name);
2424
} catch (error) {
2525
console.error(error);
2626
}
2727
}
28+
29+
async function largeFileUpload(client, file) {
30+
try {
31+
let options = {
32+
path: "/Documents",
33+
fileName: file.name,
34+
rangeSize: 1024 * 1024,
35+
};
36+
const uploadTask = await MicrosoftGraph.OneDriveLargeFileUploadTask.create(client, file, options);
37+
const response = await uploadTask.upload();
38+
console.log(response);
39+
console.log("File Uploaded Successfully.!!");
40+
} catch (err) {
41+
console.log(err);
42+
}
43+
}
2844
```
2945

3046
## Uploading from NodeJS
@@ -45,19 +61,15 @@ function uploadFile() {
4561
});
4662
});
4763
}
48-
```
49-
50-
## Creating session and start uploading
5164

52-
```typescript
53-
async function uploadFile(client, file) {
65+
function largeFileUpload(client, file, filename) {
5466
try {
5567
let options = {
5668
path: "/Documents",
57-
fileName: file.name,
69+
fileName,
5870
rangeSize: 1024 * 1024,
5971
};
60-
const uploadTask = await MicrosoftGraph.OneDriveLargeFileUploadTask.create(client, file, options);
72+
const uploadTask = await OneDriveLargeFileUploadTask.create(client, file, options);
6173
const response = await uploadTask.upload();
6274
console.log(response);
6375
console.log("File Uploaded Successfully.!!");

0 commit comments

Comments
 (0)