forked from Qortal/qortal
When zipping files, rename the outer folder to "data" instead of using the original folder name. This means that the data can be accessed deterministically without the need to first lookup the folder name.
This commit is contained in:
parent
1c6428dd3b
commit
3f20fadb81
@ -131,7 +131,7 @@ public class DataResource {
|
||||
// Firstly zip up the directory
|
||||
String outputFilePath = "temp/zipped.zip";
|
||||
try {
|
||||
ZipUtils.zip(directoryPath, outputFilePath);
|
||||
ZipUtils.zip(directoryPath, outputFilePath, "data");
|
||||
} catch (IOException e) {
|
||||
LOGGER.info("Unable to zip directory", e);
|
||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||
|
@ -18,11 +18,14 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class ZipUtils {
|
||||
|
||||
public static void zip(String sourcePath, String destFilePath) throws IOException {
|
||||
public static void zip(String sourcePath, String destFilePath, String fileName) throws IOException {
|
||||
File sourceFile = new File(sourcePath);
|
||||
if (fileName == null) {
|
||||
fileName = sourceFile.getName();
|
||||
}
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(destFilePath);
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream);
|
||||
ZipUtils.zip(sourceFile, sourceFile.getName(), zipOutputStream);
|
||||
ZipUtils.zip(sourceFile, fileName, zipOutputStream);
|
||||
zipOutputStream.close();
|
||||
fileOutputStream.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user