feat: !get run binary output from Run model
This commit is contained in:
@@ -41,27 +41,6 @@ class Run extends Model<RunAttributes, RunCreationAttributes> implements RunAttr
|
||||
public runId!: string;
|
||||
public serializableOutput!: Record<string, any[]>;
|
||||
public binaryOutput!: Record<string, any>;
|
||||
|
||||
public async getBinaryOutputFromMinioBucket(key: string): Promise<Buffer> {
|
||||
const bucketName = 'maxun-run-screenshots';
|
||||
|
||||
try {
|
||||
console.log(`Fetching from bucket ${bucketName} with key ${key}`);
|
||||
const stream = await minioClient.getObject(bucketName, key);
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks: Buffer[] = [];
|
||||
stream.on('data', (chunk) => chunks.push(chunk));
|
||||
stream.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
stream.on('error', (error) => {
|
||||
console.error('Error while reading the stream from MinIO:', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error fetching from MinIO bucket: ${bucketName} with key: ${key}`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Run.init(
|
||||
|
||||
Reference in New Issue
Block a user