<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleArchive",
  "identifier" : "/documentation/AppleArchive/ArchiveByteStream/compressionStream(appendingTo:flags:threadCount:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Apple Archive",
      "AppleArchive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B10ByteStreamC011compressionD011appendingTo5flags11threadCountACSgAC_AA0B5FlagsVSitFZ"
  },
  "title" : "compressionStream(appendingTo:flags:threadCount:)"
}
-->

# compressionStream(appendingTo:flags:threadCount:)

Reopens a compression sequential output stream.

```
static func compressionStream(appendingTo compressedStream: ArchiveByteStream, flags: ArchiveFlags = [], threadCount: Int = 0) -> ArchiveByteStream?
```

## Parameters

`compressedStream`

The output stream that the function reopens and receives the compressed data.

`flags`

Flags that control the behavior of the operation.

`threadCount`

The number of worker threads that the operation uses, set to `0` for default.

## Return Value

A new archive byte stream.

## Discussion

The operation writes compressed data to the end of the supplied archive byte stream, `compressedStream`. `compressedStream` must implement [`seek(toOffset:relativeTo:)`](/documentation/AppleArchive/ArchiveByteStreamProtocol/seek(toOffset:relativeTo:)), and the read and write functions.

The stream that the function returns only implements [`write(from:)`](/documentation/AppleArchive/ArchiveByteStreamProtocol/write(from:)) and [`write(from:atOffset:)`](/documentation/AppleArchive/ArchiveByteStreamProtocol/write(from:atOffset:)).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)