Address artifact PR review feedback
This commit is contained in:
@@ -57,9 +57,15 @@ export function createLocalDiskStorageProvider(baseDir: string): StorageProvider
|
||||
if (!stat || !stat.isFile()) {
|
||||
throw notFound("Object not found");
|
||||
}
|
||||
const streamOptions = input.range
|
||||
? { start: input.range.start, end: input.range.end }
|
||||
: undefined;
|
||||
const contentLength = input.range
|
||||
? input.range.end - input.range.start + 1
|
||||
: stat.size;
|
||||
return {
|
||||
stream: createReadStream(filePath),
|
||||
contentLength: stat.size,
|
||||
stream: createReadStream(filePath, streamOptions),
|
||||
contentLength,
|
||||
lastModified: stat.mtime,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -99,6 +99,7 @@ export function createS3StorageProvider(config: S3ProviderConfig): StorageProvid
|
||||
new GetObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
Range: input.range ? `bytes=${input.range.start}-${input.range.end}` : undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -113,9 +113,9 @@ export function createStorageService(provider: StorageProvider): StorageService
|
||||
};
|
||||
},
|
||||
|
||||
async getObject(companyId: string, objectKey: string) {
|
||||
async getObject(companyId: string, objectKey: string, options) {
|
||||
ensureCompanyPrefix(companyId, objectKey);
|
||||
return provider.getObject({ objectKey });
|
||||
return provider.getObject({ objectKey, range: options?.range });
|
||||
},
|
||||
|
||||
async headObject(companyId: string, objectKey: string) {
|
||||
|
||||
@@ -10,6 +10,10 @@ export interface PutObjectInput {
|
||||
|
||||
export interface GetObjectInput {
|
||||
objectKey: string;
|
||||
range?: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface GetObjectResult {
|
||||
@@ -56,7 +60,7 @@ export interface PutFileResult {
|
||||
export interface StorageService {
|
||||
provider: StorageProviderId;
|
||||
putFile(input: PutFileInput): Promise<PutFileResult>;
|
||||
getObject(companyId: string, objectKey: string): Promise<GetObjectResult>;
|
||||
getObject(companyId: string, objectKey: string, options?: Pick<GetObjectInput, "range">): Promise<GetObjectResult>;
|
||||
headObject(companyId: string, objectKey: string): Promise<HeadObjectResult>;
|
||||
deleteObject(companyId: string, objectKey: string): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user