mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Merge pull request #146 from bentranter/gzip-data-for-upload
Gzip data for upload
This commit is contained in:
11
api/api.go
11
api/api.go
@@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -74,7 +75,8 @@ func (a *AsciinemaAPI) urlForUpload() string {
|
|||||||
|
|
||||||
func (a *AsciinemaAPI) headersForUpload() map[string]string {
|
func (a *AsciinemaAPI) headersForUpload() map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"User-Agent": fmt.Sprintf("asciinema/%s %s/%s %s-%s", a.version, runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH),
|
"User-Agent": fmt.Sprintf("asciinema/%s %s/%s %s-%s", a.version, runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH),
|
||||||
|
"Content-Encoding": "gzip",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +86,12 @@ func filesForUpload(path string) (map[string]io.ReadCloser, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return map[string]io.ReadCloser{"asciicast:asciicast.json": file}, nil
|
zippedFile, err := gzip.NewReader(file)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[string]io.ReadCloser{"asciicast:asciicast.json": zippedFile}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractWarningMessage(response *http.Response) string {
|
func extractWarningMessage(response *http.Response) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user