From 65421c109cc8a297bf663d24842b47ee8f46b2d2 Mon Sep 17 00:00:00 2001 From: Eliran Bivas Date: Thu, 2 Aug 2018 11:37:17 +0300 Subject: [PATCH 1/4] cleanup unused method --- container.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/container.go b/container.go index 98eacb8..57c35c9 100644 --- a/container.go +++ b/container.go @@ -26,12 +26,6 @@ func newContainer(parentLogger logger.Logger, session *Session, alias string) (* }, nil } -func (c *Container) ListAll(input *ListAllInput, - context interface{}, - responseChan chan *Response) (*Request, error) { - return c.sendRequest(input, context, responseChan) -} - func (c *Container) ListBucket(input *ListBucketInput, context interface{}, responseChan chan *Response) (*Request, error) { From a35a1052fd8b3040d16c6b4108233a03daa04c43 Mon Sep 17 00:00:00 2001 From: Eliran Bivas Date: Thu, 2 Aug 2018 11:48:29 +0300 Subject: [PATCH 2/4] add marker --- synccontainer.go | 12 ++++++++++-- types.go | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/synccontainer.go b/synccontainer.go index 49de7f0..38008f9 100644 --- a/synccontainer.go +++ b/synccontainer.go @@ -110,8 +110,16 @@ func (sc *SyncContainer) ListBucket(input *ListBucketInput) (*Response, error) { // prepare the query path fullPath := sc.uriPrefix - if input.Path != "" { - fullPath += "?prefix=" + input.Path + if input.Path != "" || input.Marker != "" { + fullPath += "?" + params := make([]string, 0) + if input.Path != "" { + params = append(params, fmt.Sprintf("prefix=%s", input.Path)) + } + if input.Marker != "" { + params = append(params, fmt.Sprintf("marker=%s", input.Marker)) + } + fullPath += strings.Join(params, "&") } return sc.session.sendRequestAndXMLUnmarshal("GET", fullPath, nil, nil, &output) diff --git a/types.go b/types.go index e0eacda..68b241d 100644 --- a/types.go +++ b/types.go @@ -72,7 +72,8 @@ type RequestResponse struct { } type ListBucketInput struct { - Path string + Path string + Marker string } type Content struct { From 82a1617c28b7a958be210df51eaa5ca413683c5d Mon Sep 17 00:00:00 2001 From: Eliran Bivas Date: Thu, 2 Aug 2018 11:54:41 +0300 Subject: [PATCH 3/4] max keys --- synccontainer.go | 5 ++++- types.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/synccontainer.go b/synccontainer.go index 38008f9..4c5c475 100644 --- a/synccontainer.go +++ b/synccontainer.go @@ -110,7 +110,7 @@ func (sc *SyncContainer) ListBucket(input *ListBucketInput) (*Response, error) { // prepare the query path fullPath := sc.uriPrefix - if input.Path != "" || input.Marker != "" { + if input.Path != "" || input.Marker != "" || input.MaxKeys > 0 { fullPath += "?" params := make([]string, 0) if input.Path != "" { @@ -119,6 +119,9 @@ func (sc *SyncContainer) ListBucket(input *ListBucketInput) (*Response, error) { if input.Marker != "" { params = append(params, fmt.Sprintf("marker=%s", input.Marker)) } + if input.MaxKeys > 0 { + params = append(params, fmt.Sprintf("max-keys=%d", input.MaxKeys)) + } fullPath += strings.Join(params, "&") } diff --git a/types.go b/types.go index 68b241d..b512c7d 100644 --- a/types.go +++ b/types.go @@ -72,8 +72,9 @@ type RequestResponse struct { } type ListBucketInput struct { - Path string - Marker string + Path string + Marker string + MaxKeys int } type Content struct { From 72e35fcc724542572efd1b2983e263a0a9eb47f2 Mon Sep 17 00:00:00 2001 From: Eliran Bivas Date: Thu, 2 Aug 2018 12:00:25 +0300 Subject: [PATCH 4/4] add IsTruncated to output --- types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/types.go b/types.go index b512c7d..88dcdeb 100644 --- a/types.go +++ b/types.go @@ -98,6 +98,7 @@ type ListBucketOutput struct { MaxKeys string `xml:"MaxKeys"` Contents []Content `xml:"Contents"` CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"` + IsTruncated bool `xml:"IsTruncated"` } type ListAllInput struct {