-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82ae503
commit 91cc7cb
Showing
7 changed files
with
95 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { createClient } from 'webdav'; | ||
|
||
export class WebdavClientAdapter { | ||
constructor(serverConfig, username, password) { | ||
this._client = createClient( | ||
serverConfig, | ||
{ | ||
username, | ||
password, | ||
} | ||
); | ||
} | ||
|
||
async stat(path) { | ||
try { | ||
return await this._client.stat(path); | ||
} catch (error) { | ||
throw new Error(error.response && error.response.statusText ? error.response.statusText : 'Error checking if directory exists on webdav'); | ||
} | ||
} | ||
|
||
async createDirectory(path) { | ||
try { | ||
return await this._client.createDirectory(path); | ||
} catch (error) { | ||
throw new Error(error.response && error.response.statusText ? error.response.statusText : 'Error creating directory on webdav'); | ||
} | ||
} | ||
|
||
async deleteFile(path) { | ||
try { | ||
return await this._client.deleteFile(path); | ||
} catch (error) { | ||
throw new Error(error.response && error.response.statusText ? error.response.statusText : 'Error deleting file on webdav'); | ||
} | ||
} | ||
|
||
async getFileContents(filename) { | ||
try { | ||
return await this._client.getFileContents(filename); | ||
} catch (error) { | ||
throw new Error(error.response && error.response.statusText ? error.response.statusText : 'Error getting file contents webdav'); | ||
} | ||
} | ||
|
||
async getDirectoryContents(path) { | ||
try { | ||
return await this._client.getDirectoryContents(path); | ||
} catch (error) { | ||
throw new Error(error.response && error.response.statusText ? error.response.statusText : 'Error getting directory contents webdav'); | ||
} | ||
} | ||
|
||
createReadStream(path, options) { | ||
return this._client.createReadStream(path, options); | ||
} | ||
|
||
createWriteStream(path) { | ||
return this._client.createWriteStream(path); | ||
} | ||
} |
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