传输和保存 MultipartFile 实例

问题描述

我有以下方法,其简单目的是将给定 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 帖子,例如 thisthis,但这个问题并没有被触及:我正在有效地寻找创建一个全新的图像文件并将其存储在指定位置在磁盘上:write()方法 OutputStream,鉴于它需要 byte[]int 参数,似乎不适合我的用例。有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...