-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
System.IO.Compression.ZipFile.CreateFromDirectory: overloads to write to a stream rather than a file #1555
Comments
The overload will need to write a new signature on these functions public static ZipArchive Open(Stream archiveStream, ZipArchiveMode mode, Encoding entryNameEncoding);
private static void DoCreateFromDirectory(string sourceDirectoryName, Stream destinationStram, CompressionLevel? compressionLevel, bool includeBaseDirectory, Encoding entryNameEncoding); It'll be the same with a little bit of difference for @wfurt , I could try a PR for this |
we need to get API approval first. cc: @carlossanlop |
I've updated the issue to better stick to the guidelines. Please tell me if it's still lacking. Thanks for considering this! |
Thank you @halgab for making the changes.
We have another page in our documentation that provides better details about the API proposal stage: Step 3 in particular states the following:
So can you please add the code usage examples and the change log? And if you feel like adding more details to the concrete design descriptions (Rationale and usage, Proposed API), feel free to do so. Let us know if you have any questions. |
Triage: |
Related to this: https://github.com/dotnet/corefx/issues/13207 |
Any progress on this issue? I've met a requirement similar to this. It's a web api which generates several files(with |
I explored the implementation of these APIs and didn't find any hidden or unexpected blockers that could prevent adding them. It's feasible to implement these for .NET 8. I don't see much value in adding the I am going to edit the main proposal to include all the stream-based |
Looks good as proposed namespace System.IO.Compression;
public static partial class ZipFile
{
public static void CreateFromDirectory(string sourceDirectoryName, Stream destination);
public static void CreateFromDirectory(string sourceDirectoryName, Stream destination, CompressionLevel compressionLevel, bool includeBaseDirectory);
public static void CreateFromDirectory(string sourceDirectoryName, Stream destination, CompressionLevel compressionLevel, bool includeBaseDirectory, Encoding? entryNameEncoding);
public static void ExtractToDirectory(Stream source, string destinationDirectoryName) { }
public static void ExtractToDirectory(Stream source, string destinationDirectoryName, bool overwriteFiles) { }
public static void ExtractToDirectory(Stream source, string destinationDirectoryName, Encoding? entryNameEncoding) { }
public static void ExtractToDirectory(Stream source, string destinationDirectoryName, Encoding? entryNameEncoding, bool overwriteFiles) { }
} |
Rationale and usage
The
ZipFile.CreateFromDirectory
signatures all assume that we want to write the resulting file directly to the file system. But for small archives that are directly uploaded to cloud storage, this is not very efficient.Symmetrically,
ZipFile.ExtractToDirectory
overloads that take a zip stream rather than a file would be convenient to unzip cloud archives directly onto a drive.Proposed API
Zipping
Unzipping
There is a discussion below to also add overloads to
ZipFile.Open
that take a stream instead of a string, but there doesn't seem to be much value on adding those because the user can simply usenew ZipArchive(Stream, ZipArchiveMode)
.These APIs are analogous to the ones we already added in System.Formats.Tar.TarFile.
The text was updated successfully, but these errors were encountered: