-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file: unzip introduced #2692
file: unzip introduced #2692
Conversation
Nice! Some docs would be required before merging. |
I added docs, but can't test it, for some reason the google protobuff things are not compile on my machine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Some API tidiness suggestion.
import java.io.{File, FileInputStream} | ||
import java.util.zip.{ZipEntry, ZipInputStream} | ||
|
||
case class ZipArchiveMetadata(name: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is user-facing API and should preferably live in akka.stream.alpakka.file
instead. Add a getName
for Java folks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -106,6 +107,23 @@ public void flowShouldCreateZIPArchive() throws Exception { | |||
Map<String, ByteString> unzip = archiveHelper.unzip(resultFileContent); | |||
|
|||
assertThat(inputFiles, is(unzip)); | |||
Path target = Files.createTempDirectory("alpakka-tar-"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path target = Files.createTempDirectory("alpakka-tar-"); | |
Path target = Files.createTempDirectory("alpakka-zip-"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
} | ||
} | ||
|
||
@InternalApi class ZipSource(f: File, chunkSize: Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tg44 I see that ZipSource
"only" handles File
s. However what about this scenario: In a Play app a user uploads a zip file and I want to directly, without storing it on disk, unpack it and stream its content(s) to e.g. S3 buckets. This could probably be done in a Play Body parser. I guess ZipSource
would need to handle Source
to achieve that?
What do you think? Would it be somehow possible to adapt your code to support such a scenario?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current source works with file seek. I needed to parallel access files. Without File
and seeking, you need to consume the "subSources", and you can't use parallelism, which is in my opinion makes the source hard to use, and easy to misuse. (I think the tar flow works like this right now.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally understand your approach. I had a look at the tar reading example now, and I think it would be good if we could have the same for zip reading as well (in addition to your implementation). What also bothers me a bit is that for writing zip files as well as for read/writing tar file we work with sources and sinks, but for reading zip files we only allow Files now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ofc. we can implement a tar reading like API too, I just haven't needed that :) I think you can easily merge the tar reading and zip file reading logic. (Sorry, but I'm really short on time nowadays, so I can't contribute that in the next weeks.)
docs are missing, the basic test works, ideas welcome :)