Skip to content

Commit

Permalink
Hardcode text/html content type if file is html
Browse files Browse the repository at this point in the history
  • Loading branch information
bzon committed May 24, 2018
1 parent 94b3b6f commit 9c6d37c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion s3/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"net/url"
"os"
"path/filepath"
"strings"

htmltemp "html/template"

Expand All @@ -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)
Expand All @@ -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())
Expand Down

0 comments on commit 9c6d37c

Please sign in to comment.