aboutsummaryrefslogtreecommitdiff
path: root/go/operation/upload_content.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-07-15 11:04:43 -0700
committerChris Lu <chris.lu@gmail.com>2013-07-15 11:04:43 -0700
commit70fe7e6b5d487aa72a5e5cafdab6eb3447b1fcfc (patch)
treea2f1f28c1894325894d36c7a9eac5afb0f2435ed /go/operation/upload_content.go
parentc6bd4e656edaf92c8a2e44f196db156d99f96f20 (diff)
downloadseaweedfs-70fe7e6b5d487aa72a5e5cafdab6eb3447b1fcfc.tar.xz
seaweedfs-70fe7e6b5d487aa72a5e5cafdab6eb3447b1fcfc.zip
support gzip file upload, fix problem during replication of gzipped data
Diffstat (limited to 'go/operation/upload_content.go')
-rw-r--r--go/operation/upload_content.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go
index bfe2dd69b..2d6a249f2 100644
--- a/go/operation/upload_content.go
+++ b/go/operation/upload_content.go
@@ -21,12 +21,16 @@ type UploadResult struct {
Error string
}
-func Upload(uploadUrl string, filename string, reader io.Reader) (*UploadResult, error) {
+func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool) (*UploadResult, error) {
body_buf := bytes.NewBufferString("")
body_writer := multipart.NewWriter(body_buf)
h := make(textproto.MIMEHeader)
h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, filename))
h.Set("Content-Type", mime.TypeByExtension(strings.ToLower(filepath.Ext(filename))))
+ println("content is gzipped", isGzipped)
+ if isGzipped {
+ h.Set("Content-Encoding", "gzip")
+ }
file_writer, err := body_writer.CreatePart(h)
if err != nil {
log.Println("error creating form file", err)