diff options
Diffstat (limited to 'go/operation/upload_content.go')
| -rw-r--r-- | go/operation/upload_content.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go index e606ef7e3..b73ed0a66 100644 --- a/go/operation/upload_content.go +++ b/go/operation/upload_content.go @@ -21,11 +21,13 @@ type UploadResult struct { Error string } +var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"") + 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-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, fileNameEscaper.Replace(filename))) h.Set("Content-Type", mime.TypeByExtension(strings.ToLower(filepath.Ext(filename)))) if isGzipped { h.Set("Content-Encoding", "gzip") |
