aboutsummaryrefslogtreecommitdiff
path: root/weed/util/http_util.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-31 00:11:08 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-31 00:11:12 -0800
commita80ecbfe84486487c868c90fc28d14ab337524d3 (patch)
treefd404c9e71afe80f5d5b05773e81b2219e9885ff /weed/util/http_util.go
parent3b043ead49574ec7b9972a7d689186de17dda70f (diff)
downloadseaweedfs-a80ecbfe84486487c868c90fc28d14ab337524d3.tar.xz
seaweedfs-a80ecbfe84486487c868c90fc28d14ab337524d3.zip
s3: add s3 copy
fix https://github.com/chrislusf/seaweedfs/issues/1190
Diffstat (limited to 'weed/util/http_util.go')
-rw-r--r--weed/util/http_util.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/weed/util/http_util.go b/weed/util/http_util.go
index 740d41967..08007a038 100644
--- a/weed/util/http_util.go
+++ b/weed/util/http_util.go
@@ -286,3 +286,24 @@ func ReadUrlAsStream(fileUrl string, offset int64, size int, fn func(data []byte
}
}
+
+func ReadUrlAsReaderCloser(fileUrl string, rangeHeader string) (io.ReadCloser, error) {
+
+ req, err := http.NewRequest("GET", fileUrl, nil)
+ if err != nil {
+ return nil, err
+ }
+ if rangeHeader != "" {
+ req.Header.Add("Range", rangeHeader)
+ }
+
+ r, err := client.Do(req)
+ if err != nil {
+ return nil, err
+ }
+ if r.StatusCode >= 400 {
+ return nil, fmt.Errorf("%s: %s", fileUrl, r.Status)
+ }
+
+ return r.Body, nil
+}