mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 18:21:10 +10:00
Refactoring
* Refactor workspace membership system * Create setup endpoint * Use Passport.js * Several updates and fixes
This commit is contained in:
34
apps/server/src/integrations/storage/storage.service.ts
Normal file
34
apps/server/src/integrations/storage/storage.service.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { STORAGE_DRIVER_TOKEN } from './constants/storage.constants';
|
||||
import { StorageDriver } from './interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class StorageService {
|
||||
constructor(
|
||||
@Inject(STORAGE_DRIVER_TOKEN) private storageDriver: StorageDriver,
|
||||
) {}
|
||||
|
||||
async upload(filePath: string, fileContent: Buffer | any) {
|
||||
await this.storageDriver.upload(filePath, fileContent);
|
||||
}
|
||||
|
||||
async read(filePath: string): Promise<Buffer> {
|
||||
return this.storageDriver.read(filePath);
|
||||
}
|
||||
|
||||
async exists(filePath: string): Promise<boolean> {
|
||||
return this.storageDriver.exists(filePath);
|
||||
}
|
||||
|
||||
async signedUrl(path: string, expireIn: number): Promise<string> {
|
||||
return this.storageDriver.getSignedUrl(path, expireIn);
|
||||
}
|
||||
|
||||
url(filePath: string): string {
|
||||
return this.storageDriver.getUrl(filePath);
|
||||
}
|
||||
|
||||
async delete(filePath: string): Promise<void> {
|
||||
await this.storageDriver.delete(filePath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user