File tree Expand file tree Collapse file tree 5 files changed +12
-6
lines changed Expand file tree Collapse file tree 5 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ POST localhost:5001/v1/api/uploadFile/
3636Retorno de sucesso:
3737``` json
3838{
39- "message" : " File upload with success!"
39+ "message" : " File upload with success!" ,
40+ "file" : " bd40728a-e82b-4dce-91e0-c6d4701ab7ef.csv"
4041}
4142```
4243----
Original file line number Diff line number Diff line change @@ -13,11 +13,12 @@ class Files implements IFileController {
1313 if ( ! body . files ) {
1414 throw new Error ( "Doesn't have a file with csv format to upload" ) ;
1515 }
16- await FileService . handlerFilesPerson ( body . files ) ;
16+ const file = await FileService . handlerFilesPerson ( body . files ) ;
1717
1818 ctx . response . status = Status . Created ;
1919 return ctx . response . body = {
2020 message : "File upload with success!" ,
21+ file
2122 } ;
2223 // deno-lint-ignore no-explicit-any
2324 } catch ( er : Error | any | unknown ) {
Original file line number Diff line number Diff line change @@ -18,14 +18,15 @@ export class FileService implements IFileService {
1818 this . fileRepository = FileRespository ;
1919 }
2020
21- public async handlerFilesPerson ( files : Array < FormDataFile > ) : Promise < void > {
21+ public async handlerFilesPerson ( files : Array < FormDataFile > ) : Promise < string > {
2222 return this . processFilesPerson ( files ) ;
2323 }
2424
25- private async processFilesPerson ( files : Array < FormDataFile > ) : Promise < void > {
25+ private async processFilesPerson ( files : Array < FormDataFile > ) : Promise < string > {
2626 if ( ! files ) {
2727 throw new Error ( 'The file is required' ) ;
2828 }
29+ let name = '' ;
2930
3031 for ( const file of files ) {
3132 const isTypeCsvOrXml = file . contentType === "text/csv" ||
@@ -45,8 +46,11 @@ export class FileService implements IFileService {
4546 await this . s3 . handlerBucket ( whithoutHeader , filename ) ;
4647
4748 await this . fileRepository . handleCreate ( filename ) ;
49+
50+ name = filename ;
4851 }
4952 }
53+ return name ;
5054 }
5155
5256 public async listFiles ( ) : Promise < Array < IFileDTO > > {
Original file line number Diff line number Diff line change 11import { RouterContext } from '$deps' ;
22
3- export type CSVType = { message : string } | undefined ;
3+ export type CSVType = { message : string , file : string } | undefined ;
44export interface IFileController {
55 uploadCsv ( ctx : RouterContext < string > ) : Promise < CSVType > ;
66}
Original file line number Diff line number Diff line change 11import { FormDataFile , PutObjectOutput } from '$deps' ;
22export interface IFileService {
3- handlerFilesPerson ( files : Array < FormDataFile > ) : Promise < void >
3+ handlerFilesPerson ( files : Array < FormDataFile > ) : Promise < string >
44}
You can’t perform that action at this time.
0 commit comments