tsoa
tsoa copied to clipboard
Fileupload using octet-stream
Sorting
-
I'm submitting a ...
- [ ] bug report
- [x] feature request
- [ ] support request
-
I confirm that I
- [x] used the search to make sure that a similar issue hasn't already been submit
Expected Behavior
Right now, is not possible to upload file using octet-stream
, only by using @UploadedFile
which is multipart-formdata
. Would be great to have option to upload files using octet-stream
(for big file upload).
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
could be generated from this:
@Post("/upload")
async streamUpload(@Request() req: Req, @Body() stream: Readable): Promise<void> {
return new Promise((resolve, reject) => {
stream.on("data", (chunk) => console.log(chunk));
stream.on("error", (chunk) => reject());
stream.on("end", (chunk) => resolve());
});
}
TSOA could automatically detects that requesting using @Body() body: Readable
should be octet-stream
.
Current Behavior
Currently, TSOA will generate (from code above)
"requestBody": {
"required": true,
"content": {
"application/json": { // this should be "application/octet-stream"
"schema": {
"type": "string",
"format": "byte"
}
}
}
}