Documentation ¶
Index ¶
- Constants
- type Error
- type S3
- func (cli *S3) BucketName() string
- func (cli *S3) CheckPartUploaded(ctx context.Context, req *UploadPartRequest) (bool, error)
- func (cli *S3) Checker(ctx context.Context, state *health.CheckState) error
- func (cli *S3) Get(key string) (io.ReadCloser, *int64, error)
- func (cli *S3) GetFromS3URL(rawURL string, style URLStyle) (io.ReadCloser, *int64, error)
- func (cli *S3) GetFromS3URLWithPSK(rawURL string, style URLStyle, psk []byte) (io.ReadCloser, *int64, error)
- func (cli *S3) GetWithPSK(key string, psk []byte) (io.ReadCloser, *int64, error)
- func (cli *S3) Head(key string) (*s3.HeadObjectOutput, error)
- func (cli *S3) PutWithPSK(key *string, reader *bytes.Reader, psk []byte) error
- func (cli *S3) Session() *session.Session
- func (cli *S3) UploadPart(ctx context.Context, req *UploadPartRequest, payload []byte) error
- func (cli *S3) UploadPartWithPsk(ctx context.Context, req *UploadPartRequest, payload []byte, psk []byte) error
- func (cli *S3) ValidateBucket() error
- type S3CryptoClient
- type S3CryptoUploader
- type S3SDKClient
- type S3SDKUploader
- type S3Url
- func NewURL(region, bucketName, key string) (*S3Url, error)
- func NewURLWithScheme(scheme, region, bucketName, key string) (*S3Url, error)
- func ParseAliasVirtualHostedURL(avhURL string) (*S3Url, error)
- func ParseGlobalPathStyleURL(gpURL string) (*S3Url, error)
- func ParseGlobalVirtualHostedURL(gvhURL string) (*S3Url, error)
- func ParsePathStyleURL(pathStyleURL string) (*S3Url, error)
- func ParseURL(rawURL string, style URLStyle) (*S3Url, error)
- func ParseVirtualHostedURL(vhURL string) (*S3Url, error)
- type URLStyle
- type UploadPartRequest
- type Uploader
- func (u *Uploader) Session() *session.Session
- func (u *Uploader) Upload(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
- func (u *Uploader) UploadWithContext(ctx context.Context, input *s3manager.UploadInput, ...) (*s3manager.UploadOutput, error)
- func (u *Uploader) UploadWithPSK(input *s3manager.UploadInput, psk []byte) (*s3manager.UploadOutput, error)
- func (u *Uploader) UploadWithPSKAndContext(ctx context.Context, input *s3manager.UploadInput, psk []byte, ...) (*s3manager.UploadOutput, error)
- func (u *Uploader) ValidateInput(input *s3manager.UploadInput) (log.Data, error)
Constants ¶
const ( // PathStyle example: 'https://s3-eu-west-1.amazonaws.com/myBucket/my/s3/object/key' PathStyle = iota // GlobalPathStyle example: 'https://s3.amazonaws.com/myBucket/my/s3/object/key' GlobalPathStyle // VirtualHostedStyle example: 'https://myBucket.s3-eu-west-1.amazonaws.com/my/s3/object/key' VirtualHostedStyle // GlobalVirtualHostedStyle example: 'https://myBucket.s3.amazonaws.com/my/s3/object/key' GlobalVirtualHostedStyle // AliasVirtualHostedStyle example: 'https://myBucket/my/s3/object/key' AliasVirtualHostedStyle )
Possible S3 URL format styles, as defined in https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
const MsgHealthy = "S3 is healthy"
MsgHealthy is the message in the Check structure when S3 is healthy
const ServiceName = "S3"
ServiceName S3
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶ added in v1.7.0
type Error struct {
// contains filtered or unexported fields
}
Error is the s3client package's error type
type S3 ¶
type S3 struct {
// contains filtered or unexported fields
}
S3 client with SDK client, CryptoClient and BucketName
func InstantiateClient ¶ added in v1.2.0
func InstantiateClient(sdkClient S3SDKClient, cryptoClient S3CryptoClient, bucketName, region string, s *session.Session) *S3
InstantiateClient creates a new instance of S3 struct with the provided clients, bucket and region
func NewClient ¶ added in v1.2.0
NewClient creates a new S3 Client configured for the given region and bucket name. Note: This function will create a new session, if you already have a session, please use NewUploaderWithSession instead Any error establishing the AWS session will be returned
func NewClientWithSession ¶ added in v1.2.0
NewClientWithSession creates a new S3 Client configured for the given bucket name, using the provided session and region within it.
func (*S3) BucketName ¶
BucketName returns the bucket name used by this S3 client
func (*S3) CheckPartUploaded ¶ added in v1.2.0
CheckPartUploaded returns true only if the chunk corresponding to the provided chunkNumber has been uploaded. If all the chunks have been uploaded, we complete the upload operation.
func (*S3) Checker ¶
Checker validates that the S3 bucket exists, and updates the provided CheckState accordingly. Any error during the state update will be returned
func (*S3) Get ¶
Get returns an io.ReadCloser instance for the given path (inside the bucket configured for this client) and the content length (size in bytes). They 'key' parameter refers to the path for the file under the bucket.
func (*S3) GetFromS3URL ¶ added in v1.1.0
GetFromS3URL returns an io.ReadCloser instance and the content length (size in bytes) for the given S3 URL, in the format specified by URLStyle. More information about s3 URL styles: https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html If the URL defines a region (if provided) or bucket different from the one configured in this client, an error will be returned.
func (*S3) GetFromS3URLWithPSK ¶ added in v1.4.0
func (cli *S3) GetFromS3URLWithPSK(rawURL string, style URLStyle, psk []byte) (io.ReadCloser, *int64, error)
GetFromS3URLWithPSK returns an io.ReadCloser instance and the content length (size in bytes) for the given S3 URL, in the format specified by URLStyle, using the provided PSK for encryption. More information about s3 URL styles: https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html If the URL defines a region (if provided) or bucket different from the one configured in this client, an error will be returned.
func (*S3) GetWithPSK ¶ added in v1.3.0
GetWithPSK returns an io.ReadCloser instance for the given path (inside the bucket configured for this client) and the content length (size in bytes). It uses the provided PSK for encryption. The 'key' parameter refers to the path for the file under the bucket.
func (*S3) Head ¶ added in v1.9.0
func (cli *S3) Head(key string) (*s3.HeadObjectOutput, error)
Head returns a HeadObjectOutput containing an object metadata obtained from ah HTTP HEAD call
func (*S3) PutWithPSK ¶ added in v1.3.0
PutWithPSK uploads the provided contents to the key in the bucket configured for this client, using the provided PSK. The 'key' parameter refers to the path for the file under the bucket.
func (*S3) UploadPart ¶ added in v1.2.0
UploadPart handles the uploading a file to AWS S3, into the bucket configured for this client
func (*S3) UploadPartWithPsk ¶ added in v1.2.0
func (cli *S3) UploadPartWithPsk(ctx context.Context, req *UploadPartRequest, payload []byte, psk []byte) error
UploadPartWithPsk handles the uploading a file to AWS S3, into the bucket configured for this client, using a user-defined psk
func (*S3) ValidateBucket ¶ added in v1.1.0
ValidateBucket checks that the bucket exists and returns an error if it does not exist or there was some other error trying to get this information.
type S3CryptoClient ¶ added in v1.1.0
type S3CryptoClient interface { UploadPartWithPSK(in *s3.UploadPartInput, psk []byte) (out *s3.UploadPartOutput, err error) GetObjectWithPSK(in *s3.GetObjectInput, psk []byte) (out *s3.GetObjectOutput, err error) PutObjectWithPSK(in *s3.PutObjectInput, psk []byte) (out *s3.PutObjectOutput, err error) }
S3CryptoClient represents the cryptoclient with methods required to upload parts with encryption
type S3CryptoUploader ¶ added in v1.2.0
type S3CryptoUploader interface {
UploadWithPSK(ctx context.Context, in *s3manager.UploadInput, psk []byte) (out *s3manager.UploadOutput, err error)
}
S3CryptoUploader represents the s3crypto Uploader with methods required to upload parts with encryption
type S3SDKClient ¶ added in v1.1.0
type S3SDKClient interface { ListMultipartUploads(in *s3.ListMultipartUploadsInput) (out *s3.ListMultipartUploadsOutput, err error) ListParts(in *s3.ListPartsInput) (out *s3.ListPartsOutput, err error) CompleteMultipartUpload(in *s3.CompleteMultipartUploadInput) (out *s3.CompleteMultipartUploadOutput, err error) CreateMultipartUpload(in *s3.CreateMultipartUploadInput) (out *s3.CreateMultipartUploadOutput, err error) UploadPart(in *s3.UploadPartInput) (out *s3.UploadPartOutput, err error) HeadBucket(in *s3.HeadBucketInput) (out *s3.HeadBucketOutput, err error) HeadObject(in *s3.HeadObjectInput) (out *s3.HeadObjectOutput, err error) GetObject(in *s3.GetObjectInput) (out *s3.GetObjectOutput, err error) }
S3SDKClient represents the sdk client with methods required by dp-s3 client
type S3SDKUploader ¶ added in v1.2.0
type S3SDKUploader interface { Upload(in *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (out *s3manager.UploadOutput, err error) UploadWithContext(ctx context.Context, in *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (out *s3manager.UploadOutput, err error) }
S3SDKUploader represents the sdk uploader with methods required by dp-s3 client
type S3Url ¶ added in v1.4.0
S3Url represents an S3 URL with bucketName, key and region (optional). This struct is intended to be used for S3 URL string manipulation/translation in its possible format styles.
func NewURL ¶
NewURL instantiates a new S3Url struct with the provided region, bucket name and object key
func NewURLWithScheme ¶ added in v1.4.0
NewURLWithScheme instantiates a new S3Url struct with the provided scheme, region, bucket and object key
func ParseAliasVirtualHostedURL ¶ added in v1.4.0
ParseAliasVirtualHostedURL creates an S3Url struct from the provided dns-alias-virtual-hosted-style url string Example: 'https://myBucket/my/s3/object/key'
func ParseGlobalPathStyleURL ¶ added in v1.4.0
ParseGlobalPathStyleURL creates an S3Url struct from the provided global-path-style url string Example: 'https://s3.amazonaws.com/myBucket/my/s3/object/key' This method is compatible with PathStyle format (if region is present in the URL, it will be ignored)
func ParseGlobalVirtualHostedURL ¶ added in v1.4.0
ParseGlobalVirtualHostedURL creates an S3Url struct from the provided global-virtual-hosted-style url string Example: 'https://myBucket.s3.amazonaws.com/my/s3/object/key'
func ParsePathStyleURL ¶ added in v1.4.0
ParsePathStyleURL creates an S3Url struct from the provided path-style url string Example: 'https://s3-eu-west-1.amazonaws.com/myBucket/my/s3/object/key'.
func ParseURL ¶ added in v1.4.0
ParseURL creates an S3Url struct from the provided rawULR and format style
func ParseVirtualHostedURL ¶ added in v1.4.0
ParseVirtualHostedURL creates an S3Url struct from the provided virtual-hosted-style url string Example: 'https://myBucket.s3-eu-west-1.amazonaws.com/my/s3/object/key'
type URLStyle ¶ added in v1.4.0
type URLStyle int
URLStyle is the type to define the URL style iota enumeration corresponding an S3 url (path, virtualHosted, etc)
type UploadPartRequest ¶ added in v1.2.0
type UploadPartRequest struct { UploadKey string Type string ChunkNumber int64 TotalChunks int FileName string }
UploadPartRequest represents a part upload request
type Uploader ¶ added in v1.2.0
type Uploader struct { *S3 // contains filtered or unexported fields }
Uploader extends S3 client in order to perform Upload operations easily using the aws s3manager package. It allows Uploads with or without user-provided PSK for encryption.
func InstantiateUploader ¶ added in v1.2.0
func InstantiateUploader(s3Client *S3, sdkUploader S3SDKUploader, cryptoUploader S3CryptoUploader) *Uploader
InstantiateUploader creates a new instance of Uploader struct with the provided clients, bucket and region
func NewUploader ¶ added in v1.2.0
NewUploader creates a new Uploader configured for the given region and bucket name. Note: This function will create a new AWS session, if you already have a valid session, please use NewUploaderWithSession instead If an error occurs while establishing the AWS session, it will be returned
func NewUploaderWithSession ¶ added in v1.2.0
NewUploaderWithSession creates a new Uploader configured for the given bucket name, using the provided session and regions defined by it.
func (*Uploader) Upload ¶ added in v1.2.0
func (u *Uploader) Upload(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
Upload uploads a file to S3 using the AWS s3Manager, which will automatically split up large objects and upload them concurrently.
func (*Uploader) UploadWithContext ¶ added in v1.8.0
func (u *Uploader) UploadWithContext(ctx context.Context, input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
Upload uploads a file to S3 using the AWS s3Manager with context, which will automatically split up large objects and upload them concurrently. The provided context may be used to abort the operation.
func (*Uploader) UploadWithPSK ¶ added in v1.2.0
func (u *Uploader) UploadWithPSK(input *s3manager.UploadInput, psk []byte) (*s3manager.UploadOutput, error)
UploadWithPSK uploads a file to S3 using cryptoclient, which allows you to encrypt the file with a given psk.
func (*Uploader) UploadWithPSKAndContext ¶ added in v1.10.0
func (u *Uploader) UploadWithPSKAndContext(ctx context.Context, input *s3manager.UploadInput, psk []byte, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
UploadWithPSKAndContext uploads a file to S3 using cryptoclient, which allows you to encrypt the file with a given psk. The provided context may be used to abort the operation.
func (*Uploader) ValidateInput ¶ added in v1.10.0
ValidateInput checks the input and returns an error if there is a bucket override mismatch or s3 key is not provided