Skip to content

Commit

Permalink
Merge pull request ipfs/go-ipfs-files#42 from ipfs/fix/multipart-parsing
Browse files Browse the repository at this point in the history
fix: manually parse the content disposition to preserve directories

This commit was moved from ipfs/go-ipfs-files@89dc171
  • Loading branch information
lidel authored Oct 5, 2021
2 parents 5c40acb + ecf58d5 commit 97be592
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion files/multipartfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ func (w *multipartWalker) nextFile() (Node, error) {

// fileName returns a normalized filename from a part.
func fileName(part *multipart.Part) string {
filename := part.FileName()
v := part.Header.Get("Content-Disposition")
_, params, err := mime.ParseMediaType(v)
if err != nil {
return ""
}
filename := params["filename"]
if escaped, err := url.QueryUnescape(filename); err == nil {
filename = escaped
} // if there is a unescape error, just treat the name as unescaped
Expand Down

0 comments on commit 97be592

Please sign in to comment.