Documentation ¶
Index ¶
- Constants
- func GetS3FileKey(fileName string, folder string) string
- func GetS3SessionCredentials(isDebug bool) *credentials.Credentials
- func URLFromFileName(region string, bucket string, fileName string) string
- type MIMEType
- type S3UploadResponse
- type S3UploadSettings
- type SessionWithHelpers
- func (s SessionWithHelpers) CopyObjectBucketToBucket(sourceBucket string, destinationBucket string, sourceFileName string, ...) error
- func (s SessionWithHelpers) DeleteObjectFromBucket(bucket string, fileName string) error
- func (s SessionWithHelpers) FileExists(bucket string, fileName string) (bool, error)
- func (s SessionWithHelpers) GetObject(bucket string, fileName string, isDebug bool) (*s3.GetObjectOutput, error)
- func (s SessionWithHelpers) GetObjectMetadata(bucket string, fileName string, isDebug bool) (map[string]*string, error)
- func (s SessionWithHelpers) GetSignedDownloadURL(bucket string, fileName string, duration time.Duration, ...) (string, error)
- func (s SessionWithHelpers) MoveObjectBucketToBucket(sourceBucket string, destinationBucket string, sourceFileName string, ...) error
- func (s SessionWithHelpers) Upload(data []byte, bucket, fileName string, metadata *map[string]*string) (*s3.PutObjectOutput, error)
- func (s SessionWithHelpers) UploadWith1DayExpiry(data []byte, bucket, fileName string, mimeType MIMEType, ...) (string, error)
- func (s SessionWithHelpers) UploadWithFileExtension(data []byte, bucket, filePrefix, fileExt string, mimeType MIMEType) (*S3UploadResponse, error)
- func (s SessionWithHelpers) UploadWithSettings(data []byte, bucket, fileName string, settings S3UploadSettings) (string, error)
- func (s SessionWithHelpers) UploadWithSettingsRevised(data []byte, bucket string, settings S3UploadSettings) (S3UploadResponse, error)
Constants ¶
View Source
const ( S3ExpiryDuration1Day time.Duration = 24 * time.Hour S3ExpiryDuration7Days time.Duration = 7 * 24 * time.Hour )
Duration constants
Variables ¶
This section is empty.
Functions ¶
func GetS3FileKey ¶
func GetS3SessionCredentials ¶ added in v1.89.0
func GetS3SessionCredentials(isDebug bool) *credentials.Credentials
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 ¶
type SessionWithHelpers ¶
func GetSession ¶ added in v1.88.0
func GetSession(isDebug bool, region ...string) *SessionWithHelpers
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 (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 ¶ added in v1.51.0
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 ¶
func (s SessionWithHelpers) UploadWithSettings(data []byte, bucket, fileName string, settings S3UploadSettings) (string, error)
func (SessionWithHelpers) UploadWithSettingsRevised ¶ added in v1.51.0
func (s SessionWithHelpers) UploadWithSettingsRevised(data []byte, bucket string, settings S3UploadSettings) (S3UploadResponse, error)
UploadWithSettingsRevised can be renamed to UploadWithSettings once original function has been deprecated.
Click to show internal directories.
Click to hide internal directories.