From 8b0f9b701865b8992c88bcf5068818f28bd63fed Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 23 May 2015 12:58:53 -0700 Subject: [PATCH] Handle 0byte file downloads properly --- Godeps/Godeps.json | 2 +- .../minio/objectstorage-go/low_level_api.go | 7 ++++--- cmd-options.go | 12 ++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 6010d026..565c0721 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -36,7 +36,7 @@ }, { "ImportPath": "github.com/minio/objectstorage-go", - "Rev": "883ebdb4593b397713be5f0818174f71ee6724e0" + "Rev": "7e4b2520052fedcc40be93c93cbb13688d11285d" }, { "ImportPath": "github.com/shiena/ansicolor", diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_api.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_api.go index 907b571a..f16b88a3 100644 --- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_api.go +++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_api.go @@ -401,12 +401,13 @@ func (a *lowLevelAPI) getObjectRequest(bucket, object string, offset, length uin if err != nil { return nil, err } - // TODO - fix this to support full - http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html switch { - case length > 0: + case length > 0 && offset > 0: r.Set("Range", fmt.Sprintf("bytes=%d-%d", offset, offset+length-1)) - default: + case offset > 0 && length == 0: r.Set("Range", fmt.Sprintf("bytes=%d-", offset)) + case length > 0 && offset == 0: + r.Set("Range", fmt.Sprintf("bytes=-%d", length)) } return r, nil } diff --git a/cmd-options.go b/cmd-options.go index a74d8e42..c9d8dba1 100644 --- a/cmd-options.go +++ b/cmd-options.go @@ -66,9 +66,9 @@ EXAMPLES: 5. List files with non english characters on Amazon S3 object storage $ mc ls s3:andoria/本... - [2015-05-19 17:21:49 PDT] 41B 本b語 - [2015-05-19 17:24:19 PDT] 41B 本b語.1 - [2015-05-19 17:28:22 PDT] 41B 本語 + [2015-05-19 17:21:49 PDT] 41B 本語.pdf + [2015-05-19 17:24:19 PDT] 41B 本語.txt + [2015-05-19 17:28:22 PDT] 41B 本語.md `, } @@ -140,7 +140,7 @@ EXAMPLES: $ mc {{.Name}} s3:documents/2014/... C:\backup\2014 C:\shared\volume\backup\2014 5. Sync a local file of non english character to Amazon s3 object storage - $ mc {{.Name}} 本語 s3:mylocaldocuments C:\backup\2014 play:backup + $ mc {{.Name}} 本語/... s3:mylocaldocuments C:\backup\2014 play:backup `, } @@ -199,6 +199,10 @@ EXAMPLES: 3. Concantenate multiple files from local filesystem to standard output. $ mc {{.Name}} *.txt > newfile.txt + + 4. Concatenate a non english file name from Amazon S3 object storage + $ mc {{.Name}} s3:andoria/本語 > /tmp/本語 + `, }