Documentation ¶
Overview ¶
The above code is a Go package that provides a service for uploading files to AWS S3, with functionality to check file size and file extension before uploading.
Index ¶
- type AllowedFileSize
- type AllowedFileTypes
- type AwsUploader
- func (au *AwsUploader) CheckExtension(ctx context.Context, filename string, entityType string) error
- func (au *AwsUploader) CheckFileSize(ctx context.Context, size int64, entityType string) error
- func (au *AwsUploader) UploadFile(ctx context.Context, entityType string, file multipart.File, ...) (string, error)
- type UploadServiceInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllowedFileSize ¶
type AllowedFileTypes ¶
type AwsUploader ¶
type AwsUploader struct { BucketRegion string BucketName string AllowedFileTypes AllowedFileTypes AllowedFileSize AllowedFileSize // contains filtered or unexported fields }
func NewAwsUploader ¶
func NewAwsUploader(accessKeyId string, secretAccessKey string, bucketRegion string, bucketName string, allowedFileTypes AllowedFileTypes, allowedFileSize AllowedFileSize) (*AwsUploader, error)
The function `NewAwsUploader` creates a new instance of `AwsUploader` with the provided parameters.
func (*AwsUploader) CheckExtension ¶
func (au *AwsUploader) CheckExtension(ctx context.Context, filename string, entityType string) error
The `CheckExtension` function is a method of the `AwsUploader` struct. It is responsible for checking the file extension of a given filename against the allowed file types for a specific entity type.
func (*AwsUploader) CheckFileSize ¶
The `CheckFileSize` function is a method of the `AwsUploader` struct. It is responsible for checking the size of a file against the maximum allowed size for a specific entity type.
func (*AwsUploader) UploadFile ¶
func (au *AwsUploader) UploadFile(ctx context.Context, entityType string, file multipart.File, header *multipart.FileHeader) (string, error)
The `UploadFile` function is responsible for uploading a file to AWS S3. It takes in the context, entityType, file, and header as parameters.
type UploadServiceInterface ¶
type UploadServiceInterface interface { UploadFile(ctx context.Context, entityType string, file multipart.File, header *multipart.FileHeader) (string, error) CheckFileSize(ctx context.Context, size int64, entityType string) error CheckExtension(ctx context.Context, filename string, entityType string) error }