fix: some bugs
This commit is contained in:
+7
-7
@@ -5,17 +5,17 @@
|
||||
|
||||
function getConfig() {
|
||||
const url = process.env.NEXTCLOUD_URL
|
||||
const user = process.env.NEXTCLOUD_USER
|
||||
const password = process.env.NEXTCLOUD_PASSWORD
|
||||
const token = process.env.NEXTCLOUD_SHARE_TOKEN
|
||||
const password = process.env.NEXTCLOUD_SHARE_PASSWORD || ''
|
||||
const basePath = process.env.NEXTCLOUD_BASE_PATH || 'Models'
|
||||
|
||||
if (!url || !user || !password) {
|
||||
throw new Error('Nextcloud non configure (NEXTCLOUD_URL, NEXTCLOUD_USER, NEXTCLOUD_PASSWORD)')
|
||||
if (!url || !token) {
|
||||
throw new Error('Nextcloud non configure (NEXTCLOUD_URL, NEXTCLOUD_SHARE_TOKEN)')
|
||||
}
|
||||
|
||||
// WebDAV base: https://cloud.example.com/remote.php/dav/files/{user}/
|
||||
const davBase = `${url.replace(/\/+$/, '')}/remote.php/dav/files/${encodeURIComponent(user)}`
|
||||
const auth = 'Basic ' + Buffer.from(`${user}:${password}`).toString('base64')
|
||||
// Public share WebDAV: https://cloud.example.com/public.php/webdav/
|
||||
const davBase = `${url.replace(/\/+$/, '')}/public.php/webdav`
|
||||
const auth = 'Basic ' + Buffer.from(`${token}:${password}`).toString('base64')
|
||||
|
||||
return { davBase, auth, basePath }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user