From 9c6d37c7af4a50d4cc269940b2ac0b651dae1bb8 Mon Sep 17 00:00:00 2001 From: John Bryan Sazon Date: Fri, 25 May 2018 02:10:51 +0800 Subject: [PATCH] Hardcode text/html content type if file is html --- cmd/version.go | 2 +- s3/upload.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/version.go b/cmd/version.go index cdad51e..d32de62 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -5,7 +5,7 @@ import ( "runtime" ) -const version = "v0.1.4" +const version = "v0.1.6" func getVersion() string { return fmt.Sprintf("%s %s/%s", version, runtime.GOOS, runtime.GOARCH) diff --git a/s3/upload.go b/s3/upload.go index 21f74af..9c511fd 100644 --- a/s3/upload.go +++ b/s3/upload.go @@ -29,6 +29,7 @@ import ( "net/url" "os" "path/filepath" + "strings" htmltemp "html/template" @@ -54,7 +55,6 @@ func UploadFile(upload Upload) (string, error) { } defer f.Close() - // Set the content-type so that the file like index.html can be viewed directly from the browser fileInfo, _ := f.Stat() var size int64 = fileInfo.Size() buffer := make([]byte, size) @@ -63,6 +63,10 @@ func UploadFile(upload Upload) (string, error) { return "", err } contentType := http.DetectContentType(buffer) + // Set the content-type so that the file like index.html can be viewed directly from the browser + if strings.Contains(upload.SrcFile, "html") { + contentType = "text/html" + } // Create a new session sess := session.Must(session.NewSession())