diff --git a/fileupload/fileupload.go b/fileupload/fileupload.go index d66945d..72f5372 100644 --- a/fileupload/fileupload.go +++ b/fileupload/fileupload.go @@ -155,7 +155,7 @@ func (h *Handler) fetch(resp http.ResponseWriter, req *http.Request) { } if h.Cdn != "" { - resp.Header().Set("Location", h.Cdn + "/" + filename) + resp.Header().Set("Location", h.Cdn+"/"+filename) resp.WriteHeader(http.StatusCreated) return } @@ -293,7 +293,7 @@ func (h *Handler) store(resp http.ResponseWriter, req *http.Request) { } if h.Cdn != "" { - resp.Header().Set("Location", h.Cdn + "/" + outFilename) + resp.Header().Set("Location", h.Cdn+"/"+outFilename) } else { resp.Header().Set("Location", "/uploads/"+outFilename) } diff --git a/fileupload/s3.go b/fileupload/s3.go index 84b0b13..e050a42 100644 --- a/fileupload/s3.go +++ b/fileupload/s3.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" awss3 "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/google/uuid" ) @@ -41,15 +41,15 @@ func (s *s3) store(r io.Reader, username string, mimeType string, basename strin s3client := awss3.NewFromConfig(cfg) _, err = s3client.PutObject(context.TODO(), &awss3.PutObjectInput{ - Bucket: &bucket, - Key: &filename, - ContentType: &mimeType, + Bucket: &bucket, + Key: &filename, + ContentType: &mimeType, ContentLength: &contentLength, - Body: r, + Body: r, }) if err != nil { return "", fmt.Errorf("failed to upload to s3 api: %v", err) } - + return filename, nil }