diff options
| author | Chris Lu <chris.lu@gmail.com> | 2013-07-29 10:09:36 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2013-07-29 10:09:36 -0700 |
| commit | e94d52c1af1a97dfe849a70cf7fe6bec2fb5c97f (patch) | |
| tree | 5a3f6e7aee0f707929f4ab4bc01accc9c02eb3e2 /go/operation/upload_content.go | |
| parent | fb53ec30f7c6dc6b2bce8640eeaf7b2fb09678ea (diff) | |
| download | seaweedfs-e94d52c1af1a97dfe849a70cf7fe6bec2fb5c97f.tar.xz seaweedfs-e94d52c1af1a97dfe849a70cf7fe6bec2fb5c97f.zip | |
replicate mime type
Diffstat (limited to 'go/operation/upload_content.go')
| -rw-r--r-- | go/operation/upload_content.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go index b73ed0a66..c452ef1dc 100644 --- a/go/operation/upload_content.go +++ b/go/operation/upload_content.go @@ -23,12 +23,15 @@ type UploadResult struct { var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"") -func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool) (*UploadResult, error) { +func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool, mtype string) (*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"`, fileNameEscaper.Replace(filename))) - h.Set("Content-Type", mime.TypeByExtension(strings.ToLower(filepath.Ext(filename)))) + if mtype == "" { + mtype = mime.TypeByExtension(strings.ToLower(filepath.Ext(filename))) + } + h.Set("Content-Type", mtype) if isGzipped { h.Set("Content-Encoding", "gzip") } |
