Skip to content

Commit

Permalink
🐛 处理onedrive e5账号文件同步文件 #224
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Nov 28, 2023
1 parent 460088a commit dc56ec6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 8 additions & 3 deletions pkg/filesystem/onedrive/onedrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ export default class OneDriveFileSystem implements FileSystem {
}
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
if (parent !== "") {
parent = `:${parent}:`;
}
return this.request(
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${parent}:/children`,
`https://graph.microsoft.com/v1.0/drive/special/approot${parent}/children`,
{
method: "POST",
headers: myHeaders,
Expand Down Expand Up @@ -116,7 +119,7 @@ export default class OneDriveFileSystem implements FileSystem {

delete(path: string): Promise<void> {
return this.request(
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${joinPath(
`https://graph.microsoft.com/v1.0/drive/special/approot:${joinPath(
this.path,
path
)}`,
Expand All @@ -136,9 +139,11 @@ export default class OneDriveFileSystem implements FileSystem {
let { path } = this;
if (path === "/") {
path = "";
} else {
path = `:${path}:`;
}
return this.request(
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${path}:/children`
`https://graph.microsoft.com/v1.0/drive/special/approot${path}/children`
).then((data) => {
const list: File[] = [];
data.value.forEach((val: any) => {
Expand Down
14 changes: 7 additions & 7 deletions pkg/filesystem/onedrive/rw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class OneDriveFileReader implements FileReader {

async read(type?: "string" | "blob"): Promise<string | Blob> {
const data = await this.fs.request(
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${joinPath(
`https://graph.microsoft.com/v1.0/drive/special/approot:${joinPath(
this.file.path,
this.file.name
)}:/content`,
Expand Down Expand Up @@ -69,18 +69,18 @@ export class OneDriveFileWriter implements FileWriter {
myHeaders.append("Content-Type", "application/json");
const uploadUrl = await this.fs
.request(
`https://graph.microsoft.com/v1.0/me/drive/special/approot:${this.path}:/createUploadSession`,
`https://graph.microsoft.com/v1.0/drive/special/approot:${this.path}:/createUploadSession`,
{
method: "POST",
headers: myHeaders,
body: JSON.stringify({
item: {
"@microsoft.graph.conflictBehavior": "replace",
description: "description",
fileSystemInfo: {
"@odata.type": "microsoft.graph.fileSystemInfo",
},
name: this.path.substring(this.path.lastIndexOf("/") + 1),
// description: "description",
// fileSystemInfo: {
// "@odata.type": "microsoft.graph.fileSystemInfo",
// },
// name: this.path.substring(this.path.lastIndexOf("/") + 1),
},
}),
}
Expand Down

0 comments on commit dc56ec6

Please sign in to comment.