🐛 #23 Fix throw error when file doesn't exist
* #23 Fix throw error when file doesn't exist Run all the tests in once without special runner Add positive scenario Move coverage to the backend build workflow
This commit is contained in:
@@ -67,7 +67,7 @@ export class FileServiceImpl {
|
||||
entity.application_id = applicationId;
|
||||
entity.upload_data = null;
|
||||
|
||||
this.repository.save(entity, context);
|
||||
await this.repository.save(entity, context);
|
||||
}
|
||||
|
||||
if (file) {
|
||||
@@ -89,7 +89,7 @@ export class FileServiceImpl {
|
||||
size: options.totalSize,
|
||||
chunks: options.totalChunks || 1,
|
||||
};
|
||||
this.repository.save(entity, context);
|
||||
await this.repository.save(entity, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,9 @@ export class FileServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
return await this.getFile({ id: entity.id, company_id: entity.company_id }, context, {
|
||||
waitForThumbnail: options.waitForThumbnail,
|
||||
});
|
||||
}
|
||||
|
||||
async exists(id: string, companyId: string, context?: CompanyExecutionContext): Promise<boolean> {
|
||||
|
||||
@@ -44,13 +44,18 @@ export class FileController {
|
||||
): Promise<void> {
|
||||
const context = getCompanyExecutionContext(request);
|
||||
const params = request.params;
|
||||
const data = await gr.services.files.download(params.id, context);
|
||||
const filename = data.name.replace(/[^a-zA-Z0-9 -_.]/g, "");
|
||||
try {
|
||||
const data = await gr.services.files.download(params.id, context);
|
||||
const filename = data.name.replace(/[^a-zA-Z0-9 -_.]/g, "");
|
||||
|
||||
response.header("Content-disposition", `attachment; filename="${filename}"`);
|
||||
if (data.size) response.header("Content-Length", data.size);
|
||||
response.type(data.mime);
|
||||
response.send(data.file);
|
||||
response.header("Content-disposition", `attachment; filename="${filename}"`);
|
||||
if (data.size) response.header("Content-Length", data.size);
|
||||
response.type(data.mime);
|
||||
response.send(data.file);
|
||||
} catch (e) {
|
||||
console.log("!!!" + e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async thumbnail(
|
||||
|
||||
Reference in New Issue
Block a user