s3

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetS3FileKey

func GetS3FileKey(fileName string, folder string) string

func URLFromFileName added in v1.37.0

func URLFromFileName(region string, bucket string, fileName string) string

Types

type MIMEType

type MIMEType string
const (
	// MIMETypePDF defines the constant for the PDF MIME type.
	MIMETypePDF MIMEType = "application/pdf"

	// MIMETypeCSV defines the constant for the CSV MIME type.
	MIMETypeCSV MIMEType = "text/csv"

	// MIMETypeZIP defines the constant for the ZIP MIME type.
	MIMETypeZIP MIMEType = "application/zip"

	// MIMETypeJSON defines the constant for the JSON MIME type.
	MIMETypeJSON MIMEType = "application/json"

	// MIMETypeText defines the constant for the Plain text MIME type.
	MIMETypeText MIMEType = "text/plain"

	// MIMETypeImage defines the constant for the Image MIME type.
	MIMETypeImage MIMEType = "image/*"

	// MIMETypePNG defines the constant for the PNG MIME type.
	MIMETypePNG MIMEType = "image/png"

	// MIMETypeDefault defines the constant for the default MIME type.
	MIMETypeDefault MIMEType = "application/octet-stream"

	// TypeXLS defines the constant for the XLS MIME type.
	MIMETypeXLS MIMEType = "application/vnd.ms-excel"

	// TypeXLSX defines the constant for the XLSX MIME type.
	MIMETypeXLSX MIMEType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)

type S3UploadResponse

type S3UploadResponse struct {
	URL      string `json:"url"`
	Filename string `json:"filename"`
	Bucket   string `json:"bucket"`
	FileSize int    `json:"file_size"`
}

S3UploadResponse defines the structure of a standard JSON response to a PDF/CSV/etc request.

type S3UploadSettings added in v1.8.0

type S3UploadSettings struct {
	MimeType              MIMEType
	RetrieveSignedUrl     bool
	ExpiryDuration        *time.Duration
	AddContentDisposition bool
	FileName              string
}

type SessionWithHelpers

type SessionWithHelpers struct {
	S3Session *s3.S3
}

func NewSession

func NewSession(session *session.Session) *SessionWithHelpers

func (SessionWithHelpers) CopyObjectBucketToBucket

func (s SessionWithHelpers) CopyObjectBucketToBucket(sourceBucket string, destinationBucket string, sourceFileName string, destinationFilename string, settings S3UploadSettings) error

CopyObjectBucketToBucket - Copy an object from one S3 bucket to another

func (SessionWithHelpers) DeleteObjectFromBucket

func (s SessionWithHelpers) DeleteObjectFromBucket(bucket string, fileName string) error

DeleteObjectFromBucket - Delete an object from an S3 bucket

func (SessionWithHelpers) FileExists

func (s SessionWithHelpers) FileExists(bucket string, fileName string) (bool, error)

func (SessionWithHelpers) GetObject

func (s SessionWithHelpers) GetObject(bucket string, fileName string, isDebug bool) (*s3.GetObjectOutput, error)

func (SessionWithHelpers) GetObjectMetadata

func (s SessionWithHelpers) GetObjectMetadata(bucket string, fileName string, isDebug bool) (map[string]*string, error)

func (SessionWithHelpers) GetSignedDownloadURL

func (s SessionWithHelpers) GetSignedDownloadURL(bucket string, fileName string, duration time.Duration, headers ...map[string]string) (string, error)

GetSignedDownloadURL gets a signed download URL for the duration. If scv is nil, a new session will be created.

func (SessionWithHelpers) MoveObjectBucketToBucket

func (s SessionWithHelpers) MoveObjectBucketToBucket(sourceBucket string, destinationBucket string, sourceFileName string, destinationFileName string, settings S3UploadSettings) error

MoveObjectBucketToBucket - Move object from one S3 bucket to another

func (SessionWithHelpers) Upload

func (s SessionWithHelpers) Upload(data []byte, bucket, fileName string, metadata *map[string]*string) (*s3.PutObjectOutput, error)

func (SessionWithHelpers) UploadWith1DayExpiry

func (s SessionWithHelpers) UploadWith1DayExpiry(data []byte, bucket, fileName string, mimeType MIMEType, shouldDownloadInsteadOfOpen bool) (string, error)

func (SessionWithHelpers) UploadWithFileExtension

func (s SessionWithHelpers) UploadWithFileExtension(data []byte, bucket, filePrefix, fileExt string, mimeType MIMEType) (*S3UploadResponse, error)

UploadWithFileExtension will upload a file to S3 and return a standard S3UploadResponse.

func (SessionWithHelpers) UploadWithSettings added in v1.8.0

func (s SessionWithHelpers) UploadWithSettings(data []byte, bucket, fileName string, settings S3UploadSettings) (string, error)

Jump to

Keyboard shortcuts

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