Skip to content

Commit

Permalink
Merge pull request #96 from RachelTucker/v5_1_x_update-complete-blob
Browse files Browse the repository at this point in the history
OTHER: updating CompleteBlob request to have optional metadata and checksum
  • Loading branch information
Sharon Shabtai authored Dec 2, 2019
2 parents 57fd8e1 + 3c9fa2a commit e99fa99
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ds3/ds3Posts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func (client *Client) CompleteBlob(request *models.CompleteBlobRequest) (*models
WithPath("/" + request.BucketName + "/" + request.ObjectName).
WithQueryParam("blob", request.Blob).
WithQueryParam("job", request.Job).
WithOptionalQueryParam("size", networking.Int64PtrToStrPtr(request.Size)).
WithChecksum(request.Checksum).
WithHeaders(request.Metadata).
Build(client.connectionInfo)

if err != nil {
Expand Down
25 changes: 25 additions & 0 deletions ds3/models/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ type CompleteBlobRequest struct {
BucketName string
ObjectName string
Blob string
Checksum Checksum
Job string
Metadata map[string]string
Size *int64
}

func NewCompleteBlobRequest(bucketName string, objectName string, blob string, job string) *CompleteBlobRequest {
Expand All @@ -45,9 +48,31 @@ func NewCompleteBlobRequest(bucketName string, objectName string, blob string, j
ObjectName: objectName,
Blob: blob,
Job: job,
Checksum: NewNoneChecksum(),
Metadata: make(map[string]string),
}
}

func (completeBlobRequest *CompleteBlobRequest) WithSize(size int64) *CompleteBlobRequest {
completeBlobRequest.Size = &size
return completeBlobRequest
}


func (completeBlobRequest *CompleteBlobRequest) WithChecksum(contentHash string, checksumType ChecksumType) *CompleteBlobRequest {
completeBlobRequest.Checksum.ContentHash = contentHash
completeBlobRequest.Checksum.Type = checksumType
return completeBlobRequest
}

func (completeBlobRequest *CompleteBlobRequest) WithMetaData(key string, values ...string) *CompleteBlobRequest {
if strings.HasPrefix(strings.ToLower(key), AMZ_META_HEADER) {
completeBlobRequest.Metadata[key] = strings.Join(values, ",")
} else {
completeBlobRequest.Metadata[strings.ToLower(AMZ_META_HEADER + key)] = strings.Join(values, ",")
}
return completeBlobRequest
}
type CompleteMultiPartUploadRequest struct {
BucketName string
ObjectName string
Expand Down

0 comments on commit e99fa99

Please sign in to comment.