Comments (11)
Hi @Romakita , how can Multer configuration be passed? I see that the only config available is the uploadDir
through server settings.
from tsed.
Hi @m0uneer ,
Actually, global settings let you to customize the uploadDir. For more, options you need to give that to the MultipartFile decorators.
@MultipartFile(multerOptions)
See you
from tsed.
Solved by installing @tsed/multipartfiles
and
import { MultipartFile } from '@tsed/multipartfiles'
In the documentation, @tsed/multipartfile
is mentioned instead of @tsed/multipartfiles
(plural)
And it looks like it should be used only for multiple files upload.
https://romakita.github.io/ts-express-decorators/#/tutorials/upload-files-with-multer?id=example
from tsed.
Hum ok. I'll fix this typo :) Thanks @naoric
from tsed.
@Controller('/')
class MyCtrl {
@Post('/file')
private uploadFile(@MultipartFile() file: Multer.File) {
}
@Post('/files')
private uploadFile(@MultipartFile() files: Multer.File[]) {
}
}
from tsed.
Hello! And where does the class Multer.File come from?
The https://romakita.github.io/ts-express-decorators/#/tutorials/upload-files-with-multer?id=example page does not describe where the Multer.File class comes from and the decorator @ MultipartFile.
from tsed.
Hi @khusamov ,
Multer come from the @types/multer
and the decorator come from 'ts-express-decorators'.
Sorry, I'll fix the documentation soon :)
from tsed.
Thanks for the answer!
In the file @types/multer/index.d.ts
I found only interface Express.Multer.File
(line 99). But I can not understand how to connect it (with import).
I found how to connect the decorator MultipartFile
with the help ofimport {MultipartFile} from 'ts-express-decorators / multipartfiles';
. At you on a site in the documentation it is passed (
from tsed.
Hello @khusamov ,
Sorry for this mistake. I've just found the right example on my old project:
import {Controller, Post} from "ts-express-decorators";
import {Multer} from "@types/multer";
type MulterFile = Express.Multer.File;
@Controller('/')
class MyCtrl {
@Post('/file')
private uploadFile(@MultipartFile() file: MulterFile) {
}
@Post('/file')
private uploadFile(@MultipartFile({dest: "/other-dir"}) file: MulterFile) {
}
}
It works normally :)
See you !
from tsed.
Documentation will be updated soon ;)
from tsed.
@MultipartFile
still not recognized, used the code from the documentation:
import { Controller, Get, Post } from '@tsed/common'
import Multer from 'multer'
type MulterFile = Express.Multer.File
export interface ViewerModel {
name: string
file: string
}
@Controller('/models')
export class ViewerModelCtrl {
@Get('/')
async renderModels() {
return 'Hello World'
}
@Post('/')
private uploadeModel(@MultiplartFile() file: MulterFile) {}
}
I get 'Cannot find name 'MultipartFile'
from tsed.
Related Issues (20)
- [BUG] Children Controller Routes should be declared before parent HOT 10
- [BUG] package installation of @tsed/typeorm and typeorm produces dependency conflict HOT 2
- [BUG] DITest cannot handle multi-instance injection HOT 2
- [BUG] Custom Inject Decorator Issue HOT 2
- [BUG] TypeError: Cannot read properties of undefined (reading 'isDone') HOT 3
- [BUG] DI resolves `alias` tokens non-deterministically HOT 4
- [BUG] @Nullable decorator does not work with unions of various objects HOT 3
- [BUG] MultipartFile doesn't show file input in Swagger HOT 1
- FormData property not available from BodyParams in a Middleware HOT 17
- [BUG] Invoke Error in platform-serverless on SQS event HOT 2
- [BUG] New implementation of "nullable" decreases the accuracy of ajv errors. HOT 4
- [BUG] @Integer annotation is no more taking into model when used with @Nullable(Number) HOT 12
- [BUG] TypeError in JsonDeserializer when handling Array of Maps HOT 9
- Run BullMQ workers $onReady? HOT 1
- [ERROR] [TSED] - TypeError: Cannot read properties of undefined (reading 'paramType') HOT 2
- Feat: Disable axios behavior HOT 23
- Option to disable cache control when caching endpoints
- [BUG] adding optional path paramater duplciates the endpoint in swagger HOT 3
- [Bug] micromatch dependency vulnerable to CVE-2024-4067 HOT 3
- [BUG] Unexpected "export" statement in ES module "PlatformLogMiddlewareSettings.js" HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsed.