![](/img/trans.png)
[英]unable to upload multiple files at once in angular + spring boot app
[英]Spring Boot multiple files upload with multiple objects
我上次需要幫助時使用單個對象上傳單個文件來創建控制器,它對我來說像
我的POJO課
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "file", "data" })
public class FileWithObject<T> {
@JsonProperty("file")
private MultipartFile file;
@JsonRawValue
@JsonProperty("data")
private T data;
}
我的休息控制器
@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;
}
我的郵遞員結果
這對我來說都是工作。 如何通過郵遞員發送對象列表,或者可以像下面的REST控制器那樣處理請求
@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;
}
如何處理對象列表
[{
"file": fileobject,
"data": "zyz"
},{
"file": fileobject,
"data": "zyz"
}]
我正在嘗試為此打擊任務創建API
我已經通過使用元數據概念完成了此操作,我在控制器和bean中所做的更改很少
調節器
@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;
}
豆角,扁豆
@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
}
圖片要求
注意:-我仍在尋找此問題的解決方法
@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;
}
希望對你有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.