I have a web service call through which zip files can be uploaded. The files are then forwarded to another service for storage, unzipping, etc.
For now the file is stored on the file system, then a FileSystemResource is built.
Resource zipFile = new FileSystemResource(tempFile.getAbsolutePath());
I could use a ByteStreamResource in order to save time(the saving of the file on disk is not needed before forwarding) but for that i need to build a byte array. In case of large files I will get an "OutOfMemory : java heap space" error.
ByteArrayResource r = new ByteArrayResource(inputStream.getBytes());
Any solutions to forwarding files without getting an OutOfMemory error using RestTemplate?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…