Skip to content

Commit 4b7eabe

Browse files
authored
Merge pull request ipfs/go-ipfs-files#14 from ipfs/fix/content-disposition-header
fix the content disposition header This commit was moved from ipfs/go-ipfs-files@883a000
2 parents ca34ecc + 8bf5a97 commit 4b7eabe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

files/multifilereader.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {
8888
// write the boundary and headers
8989
header := make(textproto.MIMEHeader)
9090
filename := url.QueryEscape(path.Join(path.Join(mfr.path...), entry.Name()))
91-
header.Set("Content-Disposition", fmt.Sprintf("file; filename=\"%s\"", filename))
91+
dispositionPrefix := "attachment"
92+
if mfr.form {
93+
dispositionPrefix = "form-data; name=\"file\""
94+
}
95+
96+
header.Set("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"", dispositionPrefix, filename))
9297

9398
var contentType string
9499

0 commit comments

Comments
 (0)