uploadfile

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

README

README

This README would normally document whatever steps are necessary to get your application up and running.

What is this repository for?
How do I get set up?
  • Summary of set up
  • Configuration
  • Dependencies
  • Database configuration
  • How to run tests
  • Deployment instructions
Contribution guidelines
  • Writing tests
  • Code review
  • Other guidelines
Who do I talk to?
  • Repo owner or admin
  • Other community or team contact

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedFileSize

type AllowedFileSize map[string]int64

type AllowedFileTypes

type AllowedFileTypes map[string][]string

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

func (au *AwsUploader) CheckFileSize(ctx context.Context, size int64, entityType string) error

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
}

Jump to

Keyboard shortcuts

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