amazon

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

Amazon

This package provides some useful abstractions for interacting with AWS.

MultPartUpload

Usage
// Get S3 client from region, and AWS API keypair
sess, err := amazon.NewS3Client("region-name", "aws-key-id", "aws-key-secret")
if err != nil {
    return err
}

// Upload a local file in parts
err = amazon.MultiPartUpload(amazon.MultiPartUploadInput{
    Ctx:               context.Background(), // Required: The context for this request
    CtxTimeout:        10 * time.Minute,     // Optional: The request will time out after this duration (defaults to 60 minutes)
    Svc:               sess,                 // Required: An AWS S3 session service for the upload
    Filepath:          "./file.txt",         // Required: A full path to a local file to PUT to S3
    DestinationBucket: "my-bucket",          // Required: The destination S3 bucket's name
    DestinationKey:    "file.txt",           // Required: The destination path in the bucket to put the file
    MaxConcurrent:     3,                    // Optional: The number of concurrent part uploads (defaults to 10)
    PartSize:          8388608,              // Optional: Number of bytes (defaults to 8MB)
})
if err != nil {
    return err
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MultiPartUpload

func MultiPartUpload(input MultiPartUploadInput) error

MultiPartUpload uploads a local file in multiple parts to AWS S3

Types

type MultiPartUploadInput

type MultiPartUploadInput struct {
	Svc               *s3.S3          // Required: An AWS S3 session service for the upload
	Ctx               context.Context // Required: The context for this request
	CtxTimeout        time.Duration   // Optional: The request will time out after this duration (defaults to 60 minutes)
	MaxConcurrent     int             // Optional: The number of concurrent part uploads (defaults to 10)
	PartSize          int64           // Optional: Number of bytes (defaults to 8MB)
	Filepath          string          // Required: A full path to a local file to PUT to S3
	DestinationBucket string          // Required: The destination S3 bucket's name
	DestinationKey    string          // Required: The destination path in the bucket to put the file
	Logger            *slog.Logger    // Optional: Handles logging if supplied
}

MultiPartUploadInput holds the inputs for a multipart upload

type MultiPartUploadResult

type MultiPartUploadResult struct {
	Error error
	Part  *s3.CompletedPart
}

MultiPartUploadResult holds the result for an individual part upload

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL