mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-06 17:19:08 +00:00
Merge branch 'main' into feat/cognito-app-client
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
Patch,
|
||||
UseInterceptors,
|
||||
UploadedFile,
|
||||
HttpException,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiConsumes,
|
||||
@@ -265,8 +266,15 @@ export class PipelinesController {
|
||||
) {
|
||||
this.logger.info('/upload - Upload Connector Route');
|
||||
const metadata = PackTheMetadata({ ...user });
|
||||
let name = `${new Date().getTime()}_${file.originalname.split('.')[0]}`;
|
||||
|
||||
const parts_of_file_name = file.originalname.split('.');
|
||||
const file_format = parts_of_file_name.pop();
|
||||
const file_name = parts_of_file_name.join('.');
|
||||
let name = `${new Date().getTime()}_${file_name}`;
|
||||
body.name ? (name = `${new Date().getTime()}_${body.name}`) : name;
|
||||
|
||||
const source_prefix = `${user.customer_name}/${name}.${file_format}`;
|
||||
|
||||
const response = await this.pipelinesClientService.uploadFile(
|
||||
{
|
||||
file,
|
||||
@@ -275,9 +283,15 @@ export class PipelinesController {
|
||||
metadata,
|
||||
);
|
||||
|
||||
const { sep, header, encoding, description } = body;
|
||||
if (!response.url) {
|
||||
this.logger.info('pipeline/upload - Failed File pipeline');
|
||||
throw new HttpException(
|
||||
'Upload failed, try again in a few minutes, if the problem persists, contact support.',
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
|
||||
const [file_name, file_format] = file.originalname.split('.');
|
||||
const { sep, header, encoding, description } = body;
|
||||
|
||||
const upload_pipeline = {
|
||||
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
|
||||
@@ -294,7 +308,7 @@ export class PipelinesController {
|
||||
properties: {
|
||||
engine: 'csv',
|
||||
source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS,
|
||||
source_prefix: `${user.customer_name}/${name}.${file_format}`,
|
||||
source_prefix,
|
||||
file_format_params: { sep, encoding, header: Boolean(header) },
|
||||
is_a_upload_csv: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user