Skip to content

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.

3 participants