forked from Qortal/qortal
Allow single files to be uploaded without compression
We may choose to save on CPU by not compressing individual files, so this allows the network to support that. However it is still using compression by default, to reduce file sizes.
This commit is contained in:
parent
236a456cae
commit
8bebe11b4e
@ -358,10 +358,18 @@ public class ArbitraryDataReader {
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO: compression types
|
||||
//if (transactionData.getCompression() == ArbitraryTransactionData.Compression.ZIP) {
|
||||
// Handle each type of compression
|
||||
if (transactionData.getCompression() == Compression.ZIP) {
|
||||
ZipUtils.unzip(this.filePath.toString(), this.uncompressedPath.getParent().toString());
|
||||
//}
|
||||
}
|
||||
else if (transactionData.getCompression() == Compression.NONE) {
|
||||
Files.createDirectories(this.uncompressedPath);
|
||||
Path finalPath = Paths.get(this.uncompressedPath.toString(), "data");
|
||||
this.filePath.toFile().renameTo(finalPath.toFile());
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(String.format("Unrecognized compression type: %s", transactionData.getCompression()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(String.format("Unable to unzip file: %s", e.getMessage()));
|
||||
}
|
||||
|
@ -65,7 +65,10 @@ public class ArbitraryDataTransactionBuilder {
|
||||
random.nextBytes(lastReference);
|
||||
}
|
||||
|
||||
ArbitraryTransactionData.Compression compression = ArbitraryTransactionData.Compression.ZIP;
|
||||
Compression compression = Compression.ZIP;
|
||||
|
||||
// FUTURE? Use zip compression for directories, or no compression for single files
|
||||
// Compression compression = (path.toFile().isDirectory()) ? Compression.ZIP : Compression.NONE;
|
||||
|
||||
ArbitraryDataWriter arbitraryDataWriter = new ArbitraryDataWriter(path, name, service, identifier, method, compression);
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user