FIX: create pipeline from any file type on upload

This commit is contained in:
Gabriel Amorim
2023-02-22 10:18:28 -03:00
parent ee8c5e7a93
commit ac3132b6eb
5 changed files with 42 additions and 18 deletions
+5
View File
@@ -10,6 +10,8 @@ export class IPipelineV2 {
@ApiProperty()
description: string;
@ApiProperty()
type: string;
@ApiProperty()
connection_id: string;
@ApiProperty()
cron: string;
@@ -104,4 +106,7 @@ export class ICreatePipelineCSVFile {
@ApiProperty()
header: boolean;
@ApiProperty()
engine: string;
}
@@ -370,13 +370,21 @@ export class PipelinesController {
@User() user: RequestUser,
@Body() body: ICreatePipelineCSVFile,
) {
this.logger.info('/upload - Upload Connector Route');
this.logger.info('/file - Upload Connector Route');
const metadata = PackTheMetadata({ ...user });
const { name, sep, header, encoding, description, file_name } = body;
const { name, sep, header, encoding, description, file_name, engine } =
body;
const file_format_params = {
...(sep && { sep }),
...(encoding && { encoding }),
...(header && { header }),
};
const source_prefix = `${user.customer_name}/${file_name}`;
const upload_pipeline = {
const upload_pipeline: ICreatePipelineV2Req = {
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
connector_name: 'Amazon S3',
connector_plugin: 'aws_s3',
@@ -387,13 +395,12 @@ export class PipelinesController {
transformations_ids: [],
tags: [],
cron: '@once',
config: { cron: '@once', tables: [] },
type: 'upload',
properties: {
engine: 'csv',
engine,
source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS,
source_prefix,
file_format_params: { sep, encoding, header: Boolean(header) },
is_a_upload_csv: true,
file_format_params,
},
input_id: undefined,
};