Skip to content

Commit dc56ec6

Browse files
committed
🐛 处理onedrive e5账号文件同步文件 #224
1 parent 460088a commit dc56ec6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

pkg/filesystem/onedrive/onedrive.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ export default class OneDriveFileSystem implements FileSystem {
6262
}
6363
const myHeaders = new Headers();
6464
myHeaders.append("Content-Type", "application/json");
65+
if (parent !== "") {
66+
parent = `:${parent}:`;
67+
}
6568
return this.request(
66-
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${parent}:/children`,
69+
`https://graph.microsoft.com/v1.0/drive/special/approot${parent}/children`,
6770
{
6871
method: "POST",
6972
headers: myHeaders,
@@ -116,7 +119,7 @@ export default class OneDriveFileSystem implements FileSystem {
116119

117120
delete(path: string): Promise<void> {
118121
return this.request(
119-
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${joinPath(
122+
`https://graph.microsoft.com/v1.0/drive/special/approot:${joinPath(
120123
this.path,
121124
path
122125
)}`,
@@ -136,9 +139,11 @@ export default class OneDriveFileSystem implements FileSystem {
136139
let { path } = this;
137140
if (path === "/") {
138141
path = "";
142+
} else {
143+
path = `:${path}:`;
139144
}
140145
return this.request(
141-
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${path}:/children`
146+
`https://graph.microsoft.com/v1.0/drive/special/approot${path}/children`
142147
).then((data) => {
143148
const list: File[] = [];
144149
data.value.forEach((val: any) => {

pkg/filesystem/onedrive/rw.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class OneDriveFileReader implements FileReader {
1818

1919
async read(type?: "string" | "blob"): Promise<string | Blob> {
2020
const data = await this.fs.request(
21-
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${joinPath(
21+
`https://graph.microsoft.com/v1.0/drive/special/approot:${joinPath(
2222
this.file.path,
2323
this.file.name
2424
)}:/content`,
@@ -69,18 +69,18 @@ export class OneDriveFileWriter implements FileWriter {
6969
myHeaders.append("Content-Type", "application/json");
7070
const uploadUrl = await this.fs
7171
.request(
72-
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${this.path}:/createUploadSession`,
72+
`https://graph.microsoft.com/v1.0/drive/special/approot:${this.path}:/createUploadSession`,
7373
{
7474
method: "POST",
7575
headers: myHeaders,
7676
body: JSON.stringify({
7777
item: {
7878
"@microsoft.graph.conflictBehavior": "replace",
79-
description: "description",
80-
fileSystemInfo: {
81-
"@odata.type": "microsoft.graph.fileSystemInfo",
82-
},
83-
name: this.path.substring(this.path.lastIndexOf("/") + 1),
79+
// description: "description",
80+
// fileSystemInfo: {
81+
// "@odata.type": "microsoft.graph.fileSystemInfo",
82+
// },
83+
// name: this.path.substring(this.path.lastIndexOf("/") + 1),
8484
},
8585
}),
8686
}

0 commit comments

Comments
 (0)