Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @param files
*/
@ApiBearerAuth()
@ApiOperation({ summary: 'Upload files' })
@ApiConsumes('multipart/form-data')
@ApiQuery({
name: 'local',
enum: ['1'],
required: false,
description: 'force use local storage',
})
@UseGuards(AnyAuthGuard)
@Post()
@UseInterceptors(
// new FastifyFileInterceptor('files'),
FilesInterceptor('files', configLoader.loadNumericConfig(ConfigKeys.UPLOADER_MAX_COUNT, 3), fileInterceptorOptions),
)
async uploader(
@Query('bucket') bucket = '',
@Query('prefix') prefix = '',
@Query('local') local: string, // 是否使用本地存储
@Req() req: AnyAuthGuard,
@UploadedFiles() files,
): Promise {
/*
if (req.fileValidationError) {
throw new UploadException(req.fileValidationError);
} */
logger.log(`upload files ${r({ bucket, prefix, files })}`);
const results = await this.saveFiles(bucket, prefix, local, files).catch(error => {
logger.error(`upload files ${r({ bucket, prefix, files })} error: ${r(error)}`);
// fs.rmdir(tempFolder).catch(reason => logger.warn(r(reason)));
@Query("value") value?: string
): Promise {
return this.service.search(keyword, value);
}
@Post("upload")
@UseInterceptors(FileInterceptor("file"))
async uploadFile(@UploadedFile() file: MediaFile): Promise {
return {
ok: true,
file: file.path
};
}
@Post("uploads")
@UseInterceptors(FilesInterceptor("files"))
async uploadFiles(
@UploadedFiles() files?: MediaFile[]
): Promise {
const fileNames = (files || []).map(item => item.path);
return {
ok: true,
files: fileNames
};
}
@Post()
async create(@Body() entry: CreateMediaDto): Promise {
return this.service.create(entry);
}
@Put()
@Query("value") value?: string
): Promise {
return this.service.search(keyword, value);
}
@Post("upload")
@UseInterceptors(FileInterceptor("file"))
async uploadFile(@UploadedFile() file: MediaFile): Promise {
return {
ok: true,
file: file.path
};
}
@Post("uploads")
@UseInterceptors(FilesInterceptor("files"))
async uploadFiles(
@UploadedFiles() files?: MediaFile[]
): Promise {
const fileNames = (files || []).map(item => item.path);
return {
ok: true,
files: fileNames
};
}
@Post()
async create(@Body() entry: CreateMediaDto): Promise {
return this.service.create(entry);
}
@Put()
@Query('value') value?: string,
): Promise {
return this.service.search(keyword, value);
}
@Post('upload')
@UseInterceptors(FileInterceptor('file'))
async uploadFile(@UploadedFile() file: MediaFile): Promise {
return {
ok: true,
file: file.path,
};
}
@Post('uploads')
@UseInterceptors(FilesInterceptor('files'))
async uploadFiles(
@UploadedFiles() files?: MediaFile[],
): Promise {
const fileNames = (files || []).map(item => item.path);
return {
ok: true,
files: fileNames,
};
}
@Post()
async create(@Body() entry: CreateMediaDto): Promise {
return this.service.create(entry);
}
@Put()