Skip to content

Commit

Permalink
cleanup multipart
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
  • Loading branch information
whyrusleeping committed Dec 27, 2015
1 parent 8011c37 commit 8e94f08
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion commands/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
// TODO extract string consts?
if fileReader != nil {
httpReq.Header.Set(contentTypeHeader, "multipart/form-data; boundary="+fileReader.Boundary())
httpReq.Header.Set(contentDispHeader, "form-data: name=\"files\"")
} else {
httpReq.Header.Set(contentTypeHeader, applicationOctetStream)
}
Expand Down
7 changes: 1 addition & 6 deletions commands/http/multifilereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {
// write the boundary and headers
header := make(textproto.MIMEHeader)
filename := url.QueryEscape(file.FileName())
if mfr.form {
contentDisposition := fmt.Sprintf("form-data; name=\"file\"; filename=\"%s\"", filename)
header.Set("Content-Disposition", contentDisposition)
} else {
header.Set("Content-Disposition", fmt.Sprintf("file; filename=\"%s\"", filename))
}
header.Set("Content-Disposition", fmt.Sprintf("file; filename=\"%s\"", filename))

header.Set("Content-Type", contentType)

Expand Down
4 changes: 4 additions & 0 deletions mfs/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func lookupDir(r *Root, path string) (*Directory, error) {
// PutNode inserts 'nd' at 'path' in the given mfs
func PutNode(r *Root, path string, nd *dag.Node) error {
dirp, filename := gopath.Split(path)
err := Mkdir(r, dirp, true)
if err != nil {
return err
}

pdir, err := lookupDir(r, dirp)
if err != nil {
Expand Down

0 comments on commit 8e94f08

Please sign in to comment.