Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add s3 infa #4

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

feature: add s3 infa #4

wants to merge 1 commit into from

Conversation

orgball2608
Copy link

Add s3 infa

Comment on lines +39 to +51
func (repo *s3Repository) SaveImageUploaded(ctx context.Context, data []byte) (*Image, error) {
fileBytes := bytes.NewReader(data)
fileType := http.DetectContentType(data)

uploadID := uuid.New().String()

_, err := repo.service.PutObject(&s3.PutObjectInput{
Bucket: aws.String(repo.service.BucketName),
Key: aws.String(uploadID),
ACL: aws.String("private"),
ContentType: aws.String(fileType),
Body: fileBytes,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sao context ở đây k dc sử dụng, có lý do gì khiến ông k dùng PutObjectWithContext()

Comment on lines +65 to +77
func (repo *s3Repository) SaveFile(ctx context.Context, data []byte, dst string) (string, error) {
fileBytes := bytes.NewReader(data)
fileType := http.DetectContentType(data)

uploadID := uuid.New().String()

_, err := repo.service.PutObject(&s3.PutObjectInput{
Bucket: aws.String(repo.service.BucketName),
Key: aws.String(uploadID),
ACL: aws.String("private"),
ContentType: aws.String(fileType),
Body: fileBytes,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context ko dc xài. với tui nghĩ từ SaveFile() khá ambiguous. Image cũng là file

Comment on lines +34 to +35
Width int `json:"width" gorm:"column:width;"`
Height int `json:"height" gorm:"column:height;"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tui vẫn chưa hình dung dc ông định dùng cái width với height của image như nào

Comment on lines +4 to +5
"elearning/config"
"log"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard package cần để lên đầu mọi thứ.

Comment on lines +34 to +39
S3ApiKey string `env:"S3_API_KEY,required=true"`
S3BucketName string `env:"S3_BUCKET_NAME,required=true"`
S3Domain string `env:"S3_DOMAIN,required=true"`
S3Region string `env:"S3_REGION,required=true"`
S3SecretKey string `env:"S3_SECRET_KEY,required=true"`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure ông cập nhật bên file example .env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants