问题描述
我有以下方法,其简单目的是将给定 multipartfile
实例的内容存储在指定目录下:
private void saveOndisk(final String clientProductId,final multipartfile image,final String parentDirectoryPath,final String fileSeparator) throws IOException
{
final File imageFile = new File(parentDirectoryPath + fileSeparator + clientProductId + image.getoriginalFilename());
image.transferTo(imageFile);
OutputStream out = new FileOutputStream(imageFile);
out. //... ? How do we proceed? OutputStream::write() requires a byte array or int as parameter
}
就其价值而言,multipartfile
实例将包含我在构建的 REST API 上收到的图像文件。
我已经检查了一些 SO 帖子,例如 this 和 this,但这个问题并没有被触及:我正在有效地寻找创建一个全新的图像文件并将其存储在指定位置在磁盘上:write()
的方法 OutputStream
,鉴于它需要 byte[]
或 int
参数,似乎不适合我的用例。有什么想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)