有什么方法可以将 File 对象转换为 MultiPartFile?这样我就可以将该对象发送到接受 MultiPartFile
接口对象的方法?
File myFile = new File("/path/to/the/file.txt")
MultiPartFile ....?
def (MultiPartFile file) {
def is = new BufferedInputStream(file.getInputStream())
//do something interesting with the stream
}
原文由 birdy 发布,翻译遵循 CC BY-SA 4.0 许可协议
MockMultipartFile 的存在就是为了这个目的。如果文件路径已知,那么在您的代码片段中,下面的代码对我有用。