You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-08 22:36:41 +02:00
fix devops upload content type
This commit is contained in:
@ -96,6 +96,7 @@ webapp:deploy:dev:
|
||||
STATIC_FILES_IMG_RESIZE: 'true'
|
||||
AWS_USE_ROLE: 'true'
|
||||
EMAIL_SENDER: 'lee+saas-starter-kit@geeksinthewoods.com'
|
||||
WEB_API_BASE_URL: https://api.eproc.tech
|
||||
|
||||
webapi:build:dev:
|
||||
<<: *build_tmpl
|
||||
@ -136,6 +137,7 @@ webapi:deploy:dev:
|
||||
STATIC_FILES_IMG_RESIZE: 'false'
|
||||
AWS_USE_ROLE: 'true'
|
||||
EMAIL_SENDER: 'lee+saas-starter-kit@geeksinthewoods.com'
|
||||
WEB_APP_BASE_URL: https://eproc.tech
|
||||
|
||||
#ddlogscollector:deploy:stage:
|
||||
# <<: *deploy_stage_tmpl
|
||||
|
@ -39,6 +39,7 @@
|
||||
{"name": "WEB_API_SERVICE_HOST_NAMES", "value": "{HOST_NAMES}"},
|
||||
{"name": "WEB_API_SERVICE_ENABLE_HTTPS", "value": "{HTTPS_ENABLED}"},
|
||||
{"name": "WEB_API_SERVICE_EMAIL_SENDER", "value": "{EMAIL_SENDER}"},
|
||||
{"name": "WEB_API_SERVICE_WEB_APP_BASE_URL", "value": "{WEB_APP_BASE_URL}"},
|
||||
{"name": "WEB_API_REDIS_HOST", "value": "{CACHE_HOST}"},
|
||||
{"name": "WEB_API_DB_HOST", "value": "{DB_HOST}"},
|
||||
{"name": "WEB_API_DB_USER", "value": "{DB_USER}"},
|
||||
|
@ -43,6 +43,7 @@
|
||||
{"name": "WEB_APP_SERVICE_STATICFILES_CLOUDFRONT_ENABLED", "value": "{STATIC_FILES_CLOUDFRONT_ENABLED}"},
|
||||
{"name": "WEB_APP_SERVICE_STATICFILES_IMG_RESIZE_ENABLED", "value": "{STATIC_FILES_IMG_RESIZE_ENABLED}"},
|
||||
{"name": "WEB_APP_SERVICE_EMAIL_SENDER", "value": "{EMAIL_SENDER}"},
|
||||
{"name": "WEB_APP_SERVICE_WEB_API_BASE_URL", "value": "{WEB_API_BASE_URL}"},
|
||||
{"name": "WEB_APP_REDIS_HOST", "value": "{CACHE_HOST}"},
|
||||
{"name": "WEB_APP_DB_HOST", "value": "{DB_HOST}"},
|
||||
{"name": "WEB_APP_DB_USER", "value": "{DB_USER}"},
|
||||
|
@ -487,7 +487,7 @@ func main() {
|
||||
staticS3UrlFormatter = func(p string) string {
|
||||
// When the path starts with a forward slash its referencing a local file,
|
||||
// make sure the static file prefix is included
|
||||
if strings.HasPrefix(p, "/") {
|
||||
if strings.HasPrefix(p, "/") || !strings.HasPrefix(p, "://") {
|
||||
p = filepath.Join(cfg.Service.StaticFiles.S3Prefix, p)
|
||||
}
|
||||
return s3UrlFormatter(p)
|
||||
@ -565,7 +565,7 @@ func main() {
|
||||
"SiteAssetUrl": func(p string) string {
|
||||
var u string
|
||||
if staticUrlFormatter != nil {
|
||||
u = staticUrlFormatter(filepath.Join(cfg.Service.Name, p))
|
||||
u = staticUrlFormatter(p)
|
||||
} else {
|
||||
if !strings.HasPrefix(p, "/") {
|
||||
p = "/" + p
|
||||
|
@ -2,13 +2,14 @@ package cicd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||
"github.com/pkg/errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// DirectoryIterator represents an iterator of a specified directory
|
||||
@ -76,11 +77,20 @@ func (di *DirectoryIterator) UploadObject() s3manager.BatchUploadObject {
|
||||
}
|
||||
|
||||
// Get file size and read the file content into a buffer
|
||||
fileInfo, _ := f.Stat()
|
||||
fileInfo, err := f.Stat()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
var size int64 = fileInfo.Size()
|
||||
buffer := make([]byte, size)
|
||||
f.Read(buffer)
|
||||
|
||||
f.Seek(0, io.SeekStart)
|
||||
|
||||
ctBuf := make([]byte, 512)
|
||||
f.Read(ctBuf)
|
||||
contentType := http.DetectContentType(ctBuf)
|
||||
|
||||
nextPath, _ := filepath.Rel(di.dir, di.next.path)
|
||||
|
||||
return s3manager.BatchUploadObject{
|
||||
@ -88,7 +98,7 @@ func (di *DirectoryIterator) UploadObject() s3manager.BatchUploadObject {
|
||||
Bucket: aws.String(di.bucket),
|
||||
Key: aws.String(filepath.Join(di.keyPrefix, nextPath)),
|
||||
Body: bytes.NewReader(buffer),
|
||||
ContentType: aws.String(http.DetectContentType(buffer)),
|
||||
ContentType: aws.String(contentType),
|
||||
ACL: acl,
|
||||
},
|
||||
After: func() error {
|
||||
|
Reference in New Issue
Block a user