mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-01-21 16:45:49 +00:00
refactor(server): download file (#1512)
* refactor(server): download file * chore: generate open-api and remove unused refs * chore(server): tests * chore: remove unused code
This commit is contained in:
18
server/libs/infra/src/storage/filesystem.provider.ts
Normal file
18
server/libs/infra/src/storage/filesystem.provider.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ImmichReadStream, IStorageRepository } from '@app/domain';
|
||||
import { constants, createReadStream, stat } from 'fs';
|
||||
import fs from 'fs/promises';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const fileInfo = promisify(stat);
|
||||
|
||||
export class FilesystemProvider implements IStorageRepository {
|
||||
async createReadStream(filepath: string, mimeType: string): Promise<ImmichReadStream> {
|
||||
const { size } = await fileInfo(filepath);
|
||||
await fs.access(filepath, constants.R_OK | constants.W_OK);
|
||||
return {
|
||||
stream: createReadStream(filepath),
|
||||
length: size,
|
||||
type: mimeType,
|
||||
};
|
||||
}
|
||||
}
|
||||
1
server/libs/infra/src/storage/index.ts
Normal file
1
server/libs/infra/src/storage/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './filesystem.provider';
|
||||
Reference in New Issue
Block a user