diff options
| author | Xe <me@christine.website> | 2022-09-15 16:10:05 +0000 |
|---|---|---|
| committer | Xe <me@christine.website> | 2022-09-15 16:10:05 +0000 |
| commit | 4fe84522878290f91a69d8bc0793eacdb6a8af6d (patch) | |
| tree | f259f468c4f0a8e8574ed5ce6cd8aa6caa3b875b /cmd/uploud/main.go | |
| parent | 82d09d6d97440f8a6764d58624ae9bc519da10c9 (diff) | |
| download | x-4fe84522878290f91a69d8bc0793eacdb6a8af6d.tar.xz x-4fe84522878290f91a69d8bc0793eacdb6a8af6d.zip | |
use tulpa.dev/cadey
Signed-off-by: Xe <me@christine.website>
Diffstat (limited to 'cmd/uploud/main.go')
| -rw-r--r-- | cmd/uploud/main.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/cmd/uploud/main.go b/cmd/uploud/main.go index f33208c..ee36893 100644 --- a/cmd/uploud/main.go +++ b/cmd/uploud/main.go @@ -11,13 +11,13 @@ import ( "path/filepath" "runtime" - "github.com/Kagami/go-avif" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "github.com/chai2010/webp" "github.com/disintegration/imaging" + "tulpa.dev/cadey/avif" ) var ( @@ -124,7 +124,6 @@ func processImage(fname, tempDir string) error { } if err := doAVIF(src, filepath.Join(tempDir, fnameBase+".avif")); err != nil { - log.Fatal(err) return err } @@ -194,9 +193,10 @@ func main() { defer fin.Close() _, err = s3c.PutObject(&s3.PutObjectInput{ - Body: fin, - Bucket: b2Bucket, - Key: aws.String(flag.Arg(1) + "/" + finfo.Name()), + Body: fin, + Bucket: b2Bucket, + Key: aws.String(flag.Arg(1) + "/" + finfo.Name()), + ContentType: aws.String(mimeTypes[filepath.Ext(finfo.Name())]), }) if err != nil { log.Fatal(err) @@ -204,6 +204,13 @@ func main() { } } +var mimeTypes = map[string]string{ + ".avif": "image/avif", + ".webp": "image/webp", + ".jpg": "image/jpeg", + ".png": "image/png", +} + func mkS3Client() *s3.S3 { s3Config := &aws.Config{ Credentials: credentials.NewStaticCredentials(os.Getenv("B2_KEY_ID"), os.Getenv("B2_APPLICATION_KEY"), ""), |
