Open dayyan opened 7 years ago
Can you provide the sample code of doing file upload with Finatra?
Here's what I tried:
postWithDoc("/file") { o =>
o.summary("Submit a new file.")
.formParam[File]("file")
.bodyParam[Metadata](name = "Metadata", description = "Metadata on the binary.")
} { request: Request => response.ok.toFuture }
I also tried:
case class ApplicationBinary(
@ApiModelProperty(dataType = "java.io.File")
fileToUpload: java.io.File
)
And using that as the dataType
.
I cannot find any example about how to do file upload with Finatra. Your example having a File field in case class, will this work? Can you provide a full example about handling the file upload, not just the swagger part?
@xiaodongw Finatra uses RequestUtils to handle file upload.
Sorry for the delay. This is how I process in a nutshell:
postWithDoc("/file") { o =>
o.summary("submit a new file")
.produces("application/json")
// examples don't work.
.formParam[File](name = "file", description = "binary to upload", true)
.consumes("multipart/form-data")
.responseWith(...
} { request: Request =>
val params = RequestUtils.multiParams(request)
ourService.submitBinary(formRequest.file, formRequest.filename)
...
Unless I'm doing this incorrectly, seems like file upload isn't supported yet.
Example in pet store: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala#L128-L133
Example in ui: http://petstore.swagger.io/#!/pet/uploadFile
I've tried both a case class with a dataType
file
, and specifyingFile
as theTypeTag
.