aboutsummaryrefslogtreecommitdiff
path: root/go/util/http_util.go
diff options
context:
space:
mode:
authortnextday <fw2k4@163.com>2015-12-15 00:14:02 +0800
committertnextday <fw2k4@163.com>2015-12-15 00:14:02 +0800
commitb177afc3263f5f33f2182f58c6156b4d77115a0b (patch)
tree15fb8beadcd0c7fb5fe1ed99b2ae7d635bd65d5b /go/util/http_util.go
parentaa44028b468674e252316a88a3b62f895b97e898 (diff)
downloadseaweedfs-b177afc3263f5f33f2182f58c6156b4d77115a0b.tar.xz
seaweedfs-b177afc3263f5f33f2182f58c6156b4d77115a0b.zip
`weed download` command use stream download the large file.
Diffstat (limited to 'go/util/http_util.go')
-rw-r--r--go/util/http_util.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/go/util/http_util.go b/go/util/http_util.go
index d56aaa39a..f80ab0c24 100644
--- a/go/util/http_util.go
+++ b/go/util/http_util.go
@@ -136,12 +136,11 @@ func GetUrlStream(url string, values url.Values, readFn func(io.Reader) error) e
return readFn(r.Body)
}
-func DownloadUrl(fileUrl string) (filename string, content []byte, e error) {
+func DownloadUrl(fileUrl string) (filename string, rc io.ReadCloser, e error) {
response, err := client.Get(fileUrl)
if err != nil {
return "", nil, err
}
- defer response.Body.Close()
contentDisposition := response.Header["Content-Disposition"]
if len(contentDisposition) > 0 {
if strings.HasPrefix(contentDisposition[0], "filename=") {
@@ -149,7 +148,7 @@ func DownloadUrl(fileUrl string) (filename string, content []byte, e error) {
filename = strings.Trim(filename, "\"")
}
}
- content, e = ioutil.ReadAll(response.Body)
+ rc = response.Body
return
}