feat(webdavclient): add method for getting directory as smartfilearray
This commit is contained in:
parent
3805d361d7
commit
fc0001b6b3
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartwebdav',
|
name: '@push.rocks/smartwebdav',
|
||||||
version: '1.0.4',
|
version: '1.1.0',
|
||||||
description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.'
|
description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.'
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,18 @@ export class WebdavClient {
|
|||||||
return result as plugins.webdav.FileStat[];
|
return result as plugins.webdav.FileStat[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getDirectoryAsSmartfileArray(pathArg: string): Promise<plugins.smartfile.SmartFile[]> {
|
||||||
|
const directoryListing = await this.listDirectory(pathArg);
|
||||||
|
const smartfileArray: plugins.smartfile.SmartFile[] = [];
|
||||||
|
for (const file of directoryListing) {
|
||||||
|
const fileContents = (await this.wdClient.getFileContents(file.filename, {
|
||||||
|
format: 'binary',
|
||||||
|
})) as Buffer;
|
||||||
|
smartfileArray.push(await plugins.smartfile.SmartFile.fromBuffer(file.filename, fileContents));
|
||||||
|
}
|
||||||
|
return smartfileArray;
|
||||||
|
}
|
||||||
|
|
||||||
public async ensureDirectory(path: string): Promise<void> {
|
public async ensureDirectory(path: string): Promise<void> {
|
||||||
console.log(`Ensuring directory at ${path}`);
|
console.log(`Ensuring directory at ${path}`);
|
||||||
const pathLevels = plugins.smartpath.get.pathLevels(path);
|
const pathLevels = plugins.smartpath.get.pathLevels(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user