Исправьте кадрирование и очистку рабочих файлов кодека
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"messenger/internal/imaging"
|
||||
)
|
||||
|
||||
type S3 struct {
|
||||
@@ -15,7 +17,10 @@ type S3 struct {
|
||||
}
|
||||
|
||||
func LoadS3(lookup Lookup) (S3, error) {
|
||||
cfg := S3{Endpoint: "http://s3:8333", Region: "us-east-1", Bucket: "messenger-attachments", MaxBytes: 10485760, MaxPixels: 40000000, StagingRetention: 24 * time.Hour}
|
||||
cfg := S3{
|
||||
Endpoint: "http://s3:8333", Region: "us-east-1", Bucket: "messenger-attachments",
|
||||
MaxBytes: imaging.MaxUploadBytes, MaxPixels: imaging.MaxImagePixels, StagingRetention: 24 * time.Hour,
|
||||
}
|
||||
for key, dest := range map[string]*string{"S3_ENDPOINT": &cfg.Endpoint, "S3_REGION": &cfg.Region, "S3_BUCKET": &cfg.Bucket} {
|
||||
if v, ok := lookup(key); ok {
|
||||
*dest = v
|
||||
@@ -32,7 +37,7 @@ func LoadS3(lookup Lookup) (S3, error) {
|
||||
key string
|
||||
dest *int64
|
||||
max int64
|
||||
}{{"MAX_UPLOAD_BYTES", &cfg.MaxBytes, 10485760}, {"MAX_IMAGE_PIXELS", &cfg.MaxPixels, 40000000}} {
|
||||
}{{"MAX_UPLOAD_BYTES", &cfg.MaxBytes, imaging.MaxUploadBytes}, {"MAX_IMAGE_PIXELS", &cfg.MaxPixels, imaging.MaxImagePixels}} {
|
||||
if v, ok := lookup(p.key); ok {
|
||||
n, e := strconv.ParseInt(v, 10, 64)
|
||||
if e != nil || n < 1 || n > p.max {
|
||||
|
||||
Reference in New Issue
Block a user