Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
chore: Add logging for files
Browse files Browse the repository at this point in the history
  • Loading branch information
devkcud committed Nov 6, 2024
1 parent 99cb7b5 commit 3bb8366
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/aws/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"image"
"io"
"log"
"mime/multipart"
"path/filepath"
"time"
Expand All @@ -31,6 +32,8 @@ var (
func (svc *AWSService) UploadFile(key string, file multipart.File) (string, error) {
newKey := fmt.Sprintf("%s/%s-%d.webp", config.Router.Environment, key, time.Now().Unix())

log.Printf("Saving file to: %s", newKey)

buf := new(bytes.Buffer)
_, err := io.Copy(buf, file)
if err != nil {
Expand Down Expand Up @@ -74,6 +77,8 @@ func (svc *AWSService) UploadFile(key string, file multipart.File) (string, erro
func (svc *AWSService) DeleteFile(key string) error {
newKey := fmt.Sprintf("%s/%s", config.Router.Environment, key)

log.Printf("Deleting file: %s", newKey)

_, err := svc.s3.DeleteObject(context.TODO(), &s3.DeleteObjectInput{
Bucket: aws.String(config.S3.Bucket),
Key: aws.String(newKey),
Expand Down

0 comments on commit 3bb8366

Please sign in to comment.