feign-form
feign-form copied to clipboard
Lower memory consumption: SpringSingleMultipartFileWriter
The write
method of SpringSingleMultipartFileWriter.java
uses a lot of memory:
@Override
protected void write (Output output, String key, Object value) throws EncodeException {
val file = (MultipartFile) value;
writeFileMetadata(output, key, file.getOriginalFilename(), file.getContentType());
byte[] bytes;
try {
bytes = file.getBytes();
} catch (IOException ex) {
throw new EncodeException("Getting multipart file's content bytes error", ex);
}
output.write(bytes);
}
Is it possible to use file.getInputStream()
in some kind of way? It will require a lot of refactoring... now large files are loaded inside the memory twice.
Facing the same issue with transferring uploaded files through Feign-equipped applications. It would be much more efficient for memory consumption if Feign could treat uploaded files as byte streams rather than byte arrays.
Same issue here. Any chance it will be fixed soon?
Looks like the support for large file isn't there. I'm facing a similar issue with pure OpenFeign described here https://github.com/OpenFeign/feign-form/issues/101 Do you guys found a workaround to this? @Toparvion @mulderga-cgi @koziolk
Looks like the support for large file isn't there. I'm facing a similar issue with pure OpenFeign described here https://github.com/OpenFeign/feign-form/issues/101
Do you guys found a workaround to this? @Toparvion @mulderga-cgi @koziolk
Yes. I've written a new client based on RestTemplate from Spring Framwork and was able to stream file content without copying it into a memory. Now I have two clients one for doing uploads and one for other operations (feign).
Thanks @koziolk for the fast response. I was thinking to do the same approach and have two clients for the short term.