MultipartFile 转成byte
时间: 2023-10-12 07:03:05 浏览: 120
SpringMVC 上传文件 MultipartFile 转为 File的方法
要将MultipartFile转换为byte数组,可以使用以下代码:
```
byte[] imgBytes = multipartFile.getBytes();
```
这将返回MultipartFile对象的字节数组表示。请确保在使用该方法之前,已经导入了相应的包,并且multipartFile对象已经被正确初始化。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [byte数组与MultipartFile相互转化](https://blog.csdn.net/qq_36964933/article/details/98474021)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Springboot byte[] 转 MultipartFile ,InputStream 转 MultipartFile](https://blog.csdn.net/qq_35387940/article/details/126537208)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文