Skip to content

Commit

Permalink
fix(cores,commons): Explicitly setting expected object size for Minio…
Browse files Browse the repository at this point in the history
… to avoid empty file failures
  • Loading branch information
fguitton committed Sep 23, 2024
1 parent 40d2fd4 commit 00c962c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/itmat-commons/src/utils/objStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ObjectStore {
return await minioClient.listBuckets();
}

public async uploadFile(fileStream: Readable, studyId: string, uri: string): Promise<string> {
public async uploadFile(fileStream: Readable, studyId: string, uri: string, size?: number): Promise<string> {
if (!this.client) {
throw new Error('Connection failed.');
}
Expand All @@ -68,7 +68,7 @@ export class ObjectStore {
throw new Error(`File "${uri}" of study "${studyId}" already exists.`);
}

const result = await this.client.putObject(lowercasestudyid, uri, fileStream);
const result = await this.client.putObject(lowercasestudyid, uri, fileStream, size);
return result.etag;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-cores/src/coreFunc/fileCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class FileCore {
);
}

await this.objStore.uploadFile(stream, defaultFileBucketId, fileUri);
await this.objStore.uploadFile(stream, defaultFileBucketId, fileUri, fileSize);

const fileEntry: IFile = {
id: uuid(),
Expand Down

0 comments on commit 00c962c

Please sign in to comment.