I need help I last time create the controller with the single file upload with an object and it's work for me like
My POJO class
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "file", "data" })
public class FileWithObject<T> {
@JsonProperty("file")
private MultipartFile file;
@JsonRawValue
@JsonProperty("data")
private T data;
}
MY REST CONTOLLER
@RequestMapping(value="/filestore/{bucket-uuid}/appsport.com/singleFileUploadWithObject/{folder}",
method = RequestMethod.POST)
@ResponseBody
// api work
public String singleFileUploadWithObject(
@PathVariable(name="bucket-uuid", required = true) String bucketUUId,
@PathVariable(name="folder", required = false) String folder,
FileWithObject rawData) {
return pingResponse;
}
My Postman result
That's all work for me. How to send the list of the objects through the postman or is possible to handle that way request like below rest controller
@RequestMapping(value="/filestore/{bucket-uuid}/appsport.com/listOfObjectsWithSingleFile/{folder}", method = RequestMethod.POST)
@ResponseBody
public String listOfObjectsWithSingleFile(
@PathVariable(name="bucket-uuid", required = true) String bucketUUId,
@PathVariable(name="folder", required = false) String folder,
Set<FileWithObject> rawData) {
return pingResponse;
}
How to handle list of objects
[{
"file": fileobject,
"data": "zyz"
},{
"file": fileobject,
"data": "zyz"
}]
I'm trying to creating the api for this blow task
I have done this by use of Meta-Data concept there are few changes I did in controller and bean
Controller
@RequestMapping(value="/filestore/{bucket-uuid}/appsport.com/listOfObjectsWithSingleFile/{folder}",
method = RequestMethod.POST)
@ResponseBody
public String listOfObjectsWithSingleFile(
@PathVariable(name="bucket-uuid") String bucketUUId, @PathVariable(name="folder") String folder,
FileWithObject objects) { // change this Set<FileWithObject> rawData to FileWithObject objects
return pingResponse;
}
Bean
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "file", "files", "data" })
public class FileWithObject<T> {
@JsonProperty("file")
private MultipartFile file;
@JsonProperty("files")
private List<MultipartFile> files;
@JsonRawValue
@JsonProperty("data")
private T data;
// work like (meta-data)
List<FileWithObject> rawData;
// getter setter
}
Image's For Request
Note:- I'm Still looking for this issue handle this in a blow way
@RequestMapping(value="/filestore/{bucketuuid}/appsport.com/listOfObjectsWithSingleFile/{folder}", method = RequestMethod.POST)
@ResponseBody
public String listOfObjectsWithSingleFile(@PathVariable(name="bucket-uuid", required = true) String bucketUUId,
@PathVariable(name="folder", required = false) String folder,Set<FileWithObject> rawData) {
return pingResponse;
}
hope it helps some one
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.