-
-
Save mnightingale/0d917379b28a1bf0cad965bd4d34beb8 to your computer and use it in GitHub Desktop.
rapidyenc decoder example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if resp.StatusCode/200 == 1 { | |
dec := rapidyenc.AcquireDecoder() | |
dec.SetReader(resp.Body) | |
request.Body = bytebufferpool.Get() | |
_, err := io.Copy(request.Body, dec) | |
// TODO: may want to ignore some errors and use partial data | |
if err != nil { | |
bytebufferpool.Put(request.Body) | |
request.Body = nil | |
rapidyenc.ReleaseDecoder(dec) | |
return err | |
} | |
meta := dec.Meta() | |
rapidyenc.ReleaseDecoder(dec) | |
request.File.Size = meta.Size | |
request.Filename = meta.Name | |
request.Offset = meta.Begin | |
request.CRC = meta.Hash | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment