s3uploader

package
v0.0.0-...-da52609 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package s3uploader provides a simple wrapper around AWS S3 SDK to upload files to S3 bucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BucketName      string
	AccessKeyID     string
	AccessKeySecret string
	Region          string
	PresignDuration time.Duration
	AccountID       string
}

Config is a struct that contains the configuration for the S3 uploader

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

Uploader is a struct that contains the AWS S3 client and uploader

func NewUploader

func NewUploader(cfg *Config) (*Uploader, error)

func (*Uploader) GetObjectPresignedUrl

func (u *Uploader) GetObjectPresignedUrl(key string) (string, error)

GetObjectPresignedUrl generates a presigned URL for the object in the S3 bucket The key is the path to the file in the bucket It returns the presigned URL The URL is in the format based on this reference: https://docs.aws.amazon.com/AmazonS3/latest/API/s3_example_s3_Scenario_PresignedUrl_section.html

func (*Uploader) GetObjectPublicUrls

func (u *Uploader) GetObjectPublicUrls(key string) string

GetObjectPublicUrls generates a public URL for the object in the S3 bucket The key is the path to the file in the bucket It returns the public URL The URL is in the format based on this reference: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access

func (*Uploader) UploadFile

func (u *Uploader) UploadFile(file multipart.File, key string) error

UploadFile uploads a file to the S3 bucket The key is the path to the file in the bucket The file is the multipart file from the request It returns an error if the upload failed

Jump to

Keyboard shortcuts

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