Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat s3 transfer manager v2 PutObject #2733

Open
wants to merge 9 commits into
base: feat-transfer-manager-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions feature/s3/transfermanager/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package transfermanager

import (
"context"

"github.com/aws/aws-sdk-go-v2/service/s3"
)

// S3Client defines a interface needed to do S3 operations at bottom logic of transfer manager
wty-Bryant marked this conversation as resolved.
Show resolved Hide resolved
// user could implement it with S3 service client for normal transfer or with customized struct for testing
type S3Client interface {
wty-Bryant marked this conversation as resolved.
Show resolved Hide resolved
PutObject(context.Context, *s3.PutObjectInput, ...func(*s3.Options)) (*s3.PutObjectOutput, error)
UploadPart(context.Context, *s3.UploadPartInput, ...func(*s3.Options)) (*s3.UploadPartOutput, error)
CreateMultipartUpload(context.Context, *s3.CreateMultipartUploadInput, ...func(*s3.Options)) (*s3.CreateMultipartUploadOutput, error)
CompleteMultipartUpload(context.Context, *s3.CompleteMultipartUploadInput, ...func(*s3.Options)) (*s3.CompleteMultipartUploadOutput, error)
AbortMultipartUpload(context.Context, *s3.AbortMultipartUploadInput, ...func(*s3.Options)) (*s3.AbortMultipartUploadOutput, error)
}
47 changes: 47 additions & 0 deletions feature/s3/transfermanager/api_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package transfermanager

import (
"github.com/aws/aws-sdk-go-v2/aws"
)

const userAgentKey = "s3-transfer"

// DefaultMaxUploadParts is the maximum allowed number of parts in a multi-part upload
// on Amazon S3.
const DefaultMaxUploadParts int32 = 10000
wty-Bryant marked this conversation as resolved.
Show resolved Hide resolved

// DefaultPartSizeBytes is the default part size when transferring objects to/from S3
const DefaultPartSizeBytes int64 = 1024 * 1024 * 8
wty-Bryant marked this conversation as resolved.
Show resolved Hide resolved

// DefaultMultipartUploadThreshold is the default size threshold in bytes indicating when to use multipart upload.
const DefaultMultipartUploadThreshold int64 = 1024 * 1024 * 16
wty-Bryant marked this conversation as resolved.
Show resolved Hide resolved

// DefaultTransferConcurrency is the default number of goroutines to spin up when
// using PutObject().
const DefaultTransferConcurrency = 5

// Client provides the API client to make operations call for Amazon Simple
// Storage Service's Transfer Manager
type Client struct {
options Options
}

// New returns an initialized Client from the client Options. Provide
// more functional options to further configure the Client
func New(s3Client S3Client, opts Options, optFns ...func(*Options)) *Client {
opts.S3 = s3Client
for _, fn := range optFns {
fn(&opts)
}

opts.init()
wty-Bryant marked this conversation as resolved.
Show resolved Hide resolved

return &Client{
options: opts,
}
}

// NewFromConfig returns a new Client from the provided s3 config
func NewFromConfig(s3Client S3Client, cfg aws.Config, optFns ...func(*Options)) *Client {
return New(s3Client, Options{}, optFns...)
}
Loading
Loading