Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/internal/offline_download/http/util.go
1562 views
1
package http
2
3
import (
4
"fmt"
5
"mime"
6
)
7
8
func parseFilenameFromContentDisposition(contentDisposition string) (string, error) {
9
if contentDisposition == "" {
10
return "", fmt.Errorf("Content-Disposition is empty")
11
}
12
_, params, err := mime.ParseMediaType(contentDisposition)
13
if err != nil {
14
return "", err
15
}
16
filename := params["filename"]
17
if filename == "" {
18
return "", fmt.Errorf("filename not found in Content-Disposition: [%s]", contentDisposition)
19
}
20
return filename, nil
21
}
22
23