-
Notifications
You must be signed in to change notification settings - Fork 0
feature: add s3 infa #4
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
base: dev
Are you sure you want to change the base?
Conversation
| 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, | ||
| }) |
There was a problem hiding this comment.
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()
| 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, | ||
| }) |
There was a problem hiding this comment.
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
| Width int `json:"width" gorm:"column:width;"` | ||
| Height int `json:"height" gorm:"column:height;"` |
There was a problem hiding this comment.
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
| "elearning/config" | ||
| "log" |
There was a problem hiding this comment.
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ứ.
| 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"` | ||
|
|
There was a problem hiding this comment.
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
Add s3 infa