Skip to content
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

Property if data is compressed #19

Open
Vario opened this issue May 8, 2019 · 2 comments
Open

Property if data is compressed #19

Vario opened this issue May 8, 2019 · 2 comments

Comments

@Vario
Copy link

Vario commented May 8, 2019

Is there a way to check if a given set of data is compressed in any way?
like data.isGzipped -> true or data.compression -> Compression.gzip || Compression.zip ,....

If not this would be a feature request

@mw99
Copy link
Owner

mw99 commented May 10, 2019

Yes that seems plausible. Will try to get this into the next release. Just some notes: This will not be possible for all compression methods. Probably only gzip and zip, because the other steams don't have an identifying header.

@Kimentanm
Copy link

extension Data {
    public var isGzipped :Bool {
        return self.starts(with: [0x1f,0x8b])
    }
}

You can use this code to check data is compressed with gzip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants