Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haruki-nikaidou/od-tree
List all files in onedrive
https://github.com/haruki-nikaidou/od-tree
Last synced: 7 days ago
JSON representation
List all files in onedrive
- Host: GitHub
- URL: https://github.com/haruki-nikaidou/od-tree
- Owner: haruki-nikaidou
- License: mit
- Created: 2023-12-26T21:52:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-07T16:59:52.000Z (about 1 year ago)
- Last Synced: 2024-11-09T02:57:48.289Z (2 months ago)
- Language: TypeScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OD Tree
List all files in onedrive as a file tree.## Usage
### Easiest way: `OdTree`
```ts
import OdTree from "onedrive-tree";
await OdTree({clientId, clientSecret, refreshToken});
```If you have got the `accessToken`, you can use
```ts
import {buildTree} from "onedrive-tree";
await buildTree(accessToken)
```## API
### Data Structure
```ts
export type FileNode = {
name: string,
size: number,
downloadUrl: string,
type: FileNodeType.File,
}export type DirectoryNode = {
name: string,
type: FileNodeType.Directory,
size?: number,
children: (FileNode | DirectoryNode)[]
}export type FileTree = DirectoryNode;
```The `token`'s type is
```ts
export type DriveToken = {
driveId: string,
accessToken: string,
}
```### Auth
+ `getAccessToken(clientId: string, clientSecret: string, tenantId: string): Promise`
+ `getOneDriveDriveId(accessToken: string): Promise`### Request But not Parse
+ `requestList(directoryId: string, token: DriveToken): Promise<(FileResponse | DirectoryResponse)[]>`
### Request and Parse
+ `recursiveBuildDirectory(directoryId: string, token: DriveToken, name: string, size?: number): Promise`
+ `buildFileTree(directoryId: string, token: DriveToken): Promise`