smartexpose/ts/classes.exposeprovider.webdav.ts
2024-04-22 13:13:00 +02:00

54 lines
1.7 KiB
TypeScript

import { ExposeProvider } from './classes.exposeprovider.js';
import * as plugins from './plugins.js';
export interface IWebdavExposeProviderOptions {
webdavCredentials: plugins.smartwebdav.IWebdavClientOptions,
webdavSubPath: string,
}
export class WebDavExposeProvider extends ExposeProvider {
public webdavClient: plugins.smartwebdav.WebdavClient;
public options: IWebdavExposeProviderOptions;
constructor(optionsArg: IWebdavExposeProviderOptions) {
super();
this.options = optionsArg;
}
public async houseKeeping (): Promise<void> {
const directoryContents = await this.webdavClient.listDirectory(this.options.webdavSubPath);
for (const fileStat of directoryContents) {
// lets read the meta.json file
if (fileStat.filename.endsWith('.json')) {
}
}
}
public async ensureBaseDir (): Promise<void> {
await this.webdavClient.ensureDirectory(this.options.webdavSubPath);
}
public async start (): Promise<void> {
this.webdavClient = new plugins.smartwebdav.WebdavClient(this.options.webdavCredentials);
await this.ensureBaseDir();
await this.houseKeeping();
}
public async stop (): Promise<void> {
// Nothing to do here
}
public async exposeFile (optionsArg: { smartFile: plugins.smartfile.SmartFile; deleteAfterMillis?: number; privateUrl?: boolean; }): Promise<{ url: string; id: string; status: 'created' | 'updated'; }> {
await this.ensureBaseDir();
}
public async wipeAll (): Promise<{ id: string; status: 'deleted' | 'failed' | 'notfound'; }[]> {
}
public async wipeFileById (idArg: string): Promise<{ id: string; status: 'deleted' | 'failed' | 'notfound'; }> {
}
}