-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feature: picture upload support webdav now
- Loading branch information
1 parent
399f4e4
commit 1dacd3c
Showing
6 changed files
with
39 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { createClient } from 'webdav' | ||
import { formatEndpoint } from '~/main/manage/utils/common' | ||
|
||
export default class WebdavApi { | ||
static async delete (configMap: IStringKeyMap): Promise<boolean> { | ||
const { fileName, config: { host, username, password, path, sslEnabled } } = configMap | ||
const endpoint = formatEndpoint(host, sslEnabled) | ||
const ctx = createClient( | ||
endpoint, | ||
{ | ||
username, | ||
password | ||
} | ||
) | ||
let key | ||
if (path === '/' || !path) { | ||
key = fileName | ||
} else { | ||
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}` | ||
} | ||
try { | ||
await ctx.deleteFile(key) | ||
return true | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters