我正在使用Apache通用CSV
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.5</version>
</dependency>
将CSV写入ByteArrayOutputStream
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final CSVFormat format = CSVFormat.DEFAULT;
final CSVPrinter csvPrinter;
try {
csvPrinter = new CSVPrinter(new PrintWriter(out), format);
csvPrinter.printRecord("12,ABC,XYZ");
csvPrinter.printRecord("13,LMN,PQR");
csvPrinter.flush();
csvPrinter.close();
} catch (IOException e) {
e.printStackTrace();
}
现在我有个假电话将文件另存为:
ResponseEntity<ObjectResponseBo> uploadFile(@RequestHeader("Authorization") String var1, @RequestParam("file") MultipartFile var2);
如何将ByteArrayOutputStream
转换为MultipartFile
对象,以便能够在Feign调用中使用csv文件?