I want to extract all the files in my .tar.gz MultipartFile and add the files to a List
@RequestMapping(value="/importFile", produces="application/json", method=RequestMethod.POST)
@ResponseBody
public ca.alea.cam.api.model.Response importFile(@RequestBody MultipartFile file) throws ContentRepositoryDaoException, Exception {
List<File> fileList = new ArrayList<File>();
InputStream in = file.getInputStream();
GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(in);
TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn);
TarArchiveEntry entry = tarIn.getNextTarEntry();
while (entry != null) {
// untar and add each file in MultipartFile to fileList
// fileList.add()...
//fileList.add(entry.getFile()) -> This returns a null, as expected from https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/tar/TarArchiveEntry.html#getFile--
}
Thanks