Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 55e9e3f

Browse files
committed
fix: manually parse the content disposition to preserve directories
fixes ipfs/kubo#8445
1 parent 544b04d commit 55e9e3f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

multipartfile.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ func (w *multipartWalker) nextFile() (Node, error) {
110110

111111
// fileName returns a normalized filename from a part.
112112
func fileName(part *multipart.Part) string {
113-
filename := part.FileName()
113+
v := part.Header.Get("Content-Disposition")
114+
_, params, err := mime.ParseMediaType(v)
115+
if err != nil {
116+
return ""
117+
}
118+
filename := params["filename"]
114119
if escaped, err := url.QueryUnescape(filename); err == nil {
115120
filename = escaped
116121
} // if there is a unescape error, just treat the name as unescaped

0 commit comments

Comments
 (0)