This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 439
/
default.js
109 lines (99 loc) · 3.9 KB
/
default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* eslint-disable no-irregular-whitespace */
const config = {
/**
* Configure the account/resource type for deployment (with 0 or 1)
* - accountType: controls account type, 0 for global, 1 for china (21Vianet)
* - driveType: controls drive resource type, 0 for onedrive, 1 for sharepoint document
*
* Followed keys is used for sharepoint resource, change them only if you gonna use sharepoint
* - hostName: sharepoint site hostname (e.g. 'name.sharepoint.com')
* - sitePath: sharepoint site path (e.g. '/sites/name')
* !Note: we do not support deploying onedrive & sharepoint at the same time
*/
type: {
accountType: 0,
driveType: 0,
hostName: null,
sitePath: null
},
refresh_token: REFRESH_TOKEN,
client_id: '6600e358-9328-4050-af82-0af9cdde796b',
client_secret: CLIENT_SECRET,
/**
* Exactly the same `redirect_uri` in your Azure Application
*/
redirect_uri: 'http://localhost',
/**
* The base path for indexing, all files and subfolders are public by this tool. For example: `/Public`.
*/
base: '/Public',
/**
* Feature: Pagination when a folder has multiple(>${top}) files
* - top: specify the page size limit of the result set, a big `top` value will slow down the fetching speed
*/
pagination: {
enable: true,
top: 100 // default: 200, accepts a minimum value of 1 and a maximum value of 999 (inclusive)
},
/**
* Feature Caching
* Enable Cloudflare cache for path pattern listed below.
* Cache rules:
* - Entire File Cache 0 < file_size < entireFileCacheLimit
* - Chunked Cache entireFileCacheLimit <= file_size < chunkedCacheLimit
* - No Cache ( redirect to OneDrive Server ) others
*
* Difference between `Entire File Cache` and `Chunked Cache`
*
* `Entire File Cache` requires the entire file to be transferred to the Cloudflare server before
* the first byte sent to a client.
*
* `Chunked Cache` would stream the file content to the client while caching it.
* But there is no exact Content-Length in the response headers. ( Content-Length: chunked )
*
* `previewCache`: using CloudFlare cache to preview
*/
cache: {
enable: true,
entireFileCacheLimit: 10000000, // 10MB
chunkedCacheLimit: 100000000, // 100MB
previewCache: false,
paths: ['/🥟%20Some%20test%20files/Previews']
},
/**
* Feature: Thumbnail
* Show a thumbnail of image by ?thumbnail=small (small, medium, large)
* More details: https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_thumbnails?view=odsp-graph-online#size-options
* Example: https://storage.spencerwoo.com/🥟%20Some%20test%20files/Previews/eb37c02438f.png?thumbnail=mediumSquare
* You can embed this link (url encoded) directly inside Markdown or HTML.
*/
thumbnail: true,
/**
* Small File Upload (<= 4MB)
* POST https://<base_url>/<directory_path>/?upload=<filename>&key=<secret_key>
* The <secret_key> is defined by you
*/
upload: {
enable: false,
key: 'your_secret_key_here'
},
/**
* Feature: Proxy Download
* Use Cloudflare as a relay to speed up download. (Especially in Mainland China)
* Example: https://storage.spencerwoo.com/🥟%20Some%20test%20files/Previews/eb37c02438f.png?raw&proxied
* You can also embed this link (url encoded) directly inside Markdown or HTML.
*/
proxyDownload: true
}
// IIFE to set apiEndpoint & baseResource
// eslint-disable-next-line no-unused-expressions
!(function({ accountType, driveType, hostName, sitePath }) {
config.apiEndpoint = {
graph: accountType ? 'https://microsoftgraph.chinacloudapi.cn/v1.0' : 'https://graph.microsoft.com/v1.0',
auth: accountType
? 'https://login.chinacloudapi.cn/common/oauth2/v2.0'
: 'https://login.microsoftonline.com/common/oauth2/v2.0'
}
config.baseResource = driveType ? `/sites/${hostName}:${sitePath}` : '/me/drive'
})(config.type)
export default config