s3

package
v1.8.13 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsS3URL added in v1.8.0

func IsS3URL(rawURL string) bool

isS3URL checks if a URL is an S3 URL

func ParseS3URL added in v1.8.0

func ParseS3URL(s3URL string) (bucket, key string, err error)

ParseS3URL parses an S3 URL and extracts bucket name and key

Types

type Client added in v1.8.1

type Client struct {
	Bucket    string
	KeyPrefix string
	Region    string
	// contains filtered or unexported fields
}

func New added in v1.3.4

func New(config ...Config) (*Client, error)

func (*Client) DeleteFile added in v1.8.1

func (s *Client) DeleteFile(ctx context.Context, key string) error

DeleteFile deletes a file from S3

func (*Client) Download added in v1.8.1

func (s *Client) Download(ctx context.Context, key string) ([]byte, error)

func (*Client) FileExists added in v1.8.1

func (s *Client) FileExists(ctx context.Context, key string) (bool, error)

FileExists checks if a file exists in S3

func (*Client) GeneratePresignedURL added in v1.8.1

func (s *Client) GeneratePresignedURL(ctx context.Context, key string, expirationMinutes int) (string, error)

GeneratePresignedURL generates a presigned URL for file access

func (*Client) GetS3FileInfo added in v1.8.1

func (s *Client) GetS3FileInfo(ctx context.Context, bucket, key string) (*FileInfo, error)

getFileInfoFromAWS gets file info using AWS SDK (for private URLs)

func (*Client) ListFiles added in v1.8.1

func (s *Client) ListFiles(ctx context.Context, maxKeys int32) ([]FileInfo, error)

ListFiles lists files in the S3 bucket with the configured prefix

func (*Client) Upload added in v1.8.1

func (s *Client) Upload(ctx context.Context, file []byte, key string, options ...UploadOptions) (string, error)

type Config added in v1.8.1

type Config struct {
	Bucket    string
	Region    string
	KeyPrefix string
}

type FileInfo added in v1.8.0

type FileInfo struct {
	Name         string     `json:"name"`
	Size         int64      `json:"size"`
	ContentType  string     `json:"content_type,omitempty"`
	LastModified *time.Time `json:"last_modified,omitempty"`
	S3Key        string     `json:"s3_key,omitempty"`
}

FileInfo contains information about a stored file

func GetFileInfoFromHTTP added in v1.8.4

func GetFileInfoFromHTTP(fileUrl string) (*FileInfo, error)

GetFileInfoFromHTTP gets file info using HTTP HEAD request (for public/signed URLs)

type S3ReturnType added in v1.8.0

type S3ReturnType string
const (
	S3ReturnTypeUrl          S3ReturnType = "url"
	S3ReturnTypePresignedUrl S3ReturnType = "presigned_url"
	S3ReturnTypeKey          S3ReturnType = "key"
)

type UploadOptions added in v1.8.0

type UploadOptions struct {
	ReturnType      S3ReturnType
	ContentType     string
	FileSize        int64
	Metadata        map[string]string
	PresignedUrlTTL time.Duration
}

Jump to

Keyboard shortcuts

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