From 90a6f43c5610cf9d05f043f2630fab56b3202a69 Mon Sep 17 00:00:00 2001 From: wangjie Date: Mon, 9 Jan 2017 14:55:21 +0800 Subject: [PATCH] fix the bug than we can't get filename when download file. --- weed/util/http_util.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/weed/util/http_util.go b/weed/util/http_util.go index 83302663e..f3e97f6f1 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -148,8 +148,9 @@ func DownloadUrl(fileUrl string) (filename string, rc io.ReadCloser, e error) { } contentDisposition := response.Header["Content-Disposition"] if len(contentDisposition) > 0 { - if strings.HasPrefix(contentDisposition[0], "filename=") { - filename = contentDisposition[0][len("filename="):] + idx := strings.Index(contentDisposition[0], "filename=") + if idx != -1 { + filename = contentDisposition[0][idx+len("filename="):] filename = strings.Trim(filename, "\"") } }