Open
Conversation
polowis
reviewed
Sep 25, 2023
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, | ||
| }) |
Contributor
There was a problem hiding this comment.
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, | ||
| }) |
Contributor
There was a problem hiding this comment.
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;"` |
Contributor
There was a problem hiding this comment.
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" |
Contributor
There was a problem hiding this comment.
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"` | ||
|
|
Contributor
There was a problem hiding this comment.
Make sure ông cập nhật bên file example .env
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add s3 infa