diff --git a/src/Inedo.UPack/Packaging/UniversalPackageBuilder.cs b/src/Inedo.UPack/Packaging/UniversalPackageBuilder.cs
index 3fea598..2a73051 100644
--- a/src/Inedo.UPack/Packaging/UniversalPackageBuilder.cs
+++ b/src/Inedo.UPack/Packaging/UniversalPackageBuilder.cs
@@ -71,7 +71,17 @@ public UniversalPackageBuilder(string fileName, UniversalPackageMetadata metadat
/// Timestamp to record for the entry.
/// Cancellation token for asynchronous operations.
/// is null or is null or empty.
- public async Task AddFileRawAsync(Stream stream, string path, DateTimeOffset timestamp, CancellationToken cancellationToken)
+ public Task AddFileRawAsync(Stream stream, string path, DateTimeOffset timestamp, CancellationToken cancellationToken) => this.AddFileRawAsync(stream, path, timestamp, CompressionLevel.Optimal, cancellationToken);
+ ///
+ /// Copies the data in the specified stream to the package using the specified raw path (relative to archive root) and timestamp.
+ ///
+ /// Source stream to copy from.
+ /// Raw path of entry to create in the package (relative to archive root).
+ /// Timestamp to record for the entry.
+ /// Compression level to use for the added file.
+ /// Cancellation token for asynchronous operations.
+ /// is null or is null or empty.
+ public async Task AddFileRawAsync(Stream stream, string path, DateTimeOffset timestamp, CompressionLevel compressionLevel, CancellationToken cancellationToken)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
@@ -79,7 +89,7 @@ public async Task AddFileRawAsync(Stream stream, string path, DateTimeOffset tim
throw new ArgumentNullException(nameof(path));
var p = path.Replace('\\', '/').Trim('/');
- var entry = this.zip.CreateEntry(p);
+ var entry = this.zip.CreateEntry(p, compressionLevel);
entry.LastWriteTime = timestamp;
using (var entryStream = entry.Open())
{
@@ -94,14 +104,24 @@ public async Task AddFileRawAsync(Stream stream, string path, DateTimeOffset tim
/// Timestamp to record for the entry.
/// Cancellation token for asynchronous operations.
/// is null or is null or empty.
- public Task AddFileAsync(Stream stream, string path, DateTimeOffset timestamp, CancellationToken cancellationToken)
+ public Task AddFileAsync(Stream stream, string path, DateTimeOffset timestamp, CancellationToken cancellationToken) => this.AddFileAsync(stream, path, timestamp, CompressionLevel.Optimal, cancellationToken);
+ ///
+ /// Copies the data in the specified stream to the package using the specified content path (relative to package directory) and timestamp.
+ ///
+ /// Source stream to copy from.
+ /// Path of entry to create in the package (relative to package directory).
+ /// Timestamp to record for the entry.
+ /// Compression level to use for the added file.
+ /// Cancellation token for asynchronous operations.
+ /// is null or is null or empty.
+ public Task AddFileAsync(Stream stream, string path, DateTimeOffset timestamp, CompressionLevel compressionLevel, CancellationToken cancellationToken)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
if (string.IsNullOrEmpty(path))
throw new ArgumentNullException(nameof(path));
- return this.AddFileRawAsync(stream, "package/" + path.Trim('/', '\\'), timestamp, cancellationToken);
+ return this.AddFileRawAsync(stream, "package/" + path.Trim('/', '\\'), timestamp, compressionLevel, cancellationToken);
}
///
/// Creates an entry for an empty directory in the package using the specified raw path (relative to archive root).