/

Compression

ByteHide Storage can compress your files before upload to significantly reduce storage space and transfer time. Files are automatically decompressed when downloaded.

Using Compression

Apply compression to individual upload operations using the Compress() method in the operation chain:

// Upload with compression
storage
    .In("documents")
    .Compress()
    .FromFile("large-report.pdf", "local/report.pdf");

// Combine with other operations
storage
    .In("images/2024")
    .Compress()
    .Encrypt()
    .FromFile("photo.jpg", "local/photo.jpg");

// Upload assembly resource with compression
storage
    .In("resources")
    .Compress()
    .FromAssembly("data.bin", Assembly.GetExecutingAssembly(), "MyProject.Resources.Data");

Storage Optimization

Compression can reduce file size by up to 80% depending on the file type, optimizing both storage space and transfer times. Text files, documents, and some image formats typically achieve the best compression rates.

Automatic Decompression

When downloading compressed files, the SDK automatically handles decompression:

// The SDK automatically detects and decompresses the file
string content = storage.GetText("documents/large-report.pdf");

// No need to specify decompression for any download method
byte[] data = storage.GetBytes("images/2024/photo.jpg");
storage.SaveToDisk("resources/data.bin", "local/data.bin");

SDK Required

Compressed files must be downloaded using the ByteHide Storage SDK to ensure proper decompression. Direct URL downloads or other methods won't automatically decompress the files.

Previous
Delete Files