Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion processing_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
// copy imgData for thread safety
imgDataForS3 := make([]byte, len(resultData.Data))
copy(imgDataForS3, resultData.Data)
uploaded = beforeResponse(imgDataForS3, cachePath)
uploaded = beforeResponse(imgDataForS3, cachePath, resultData.Type.Mime())
}

defer resultData.Close()
Expand Down
10 changes: 5 additions & 5 deletions pushd_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ func createMD5Hash(data []byte) string {
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
}

func uploadToS3(data []byte, s3Key string, uploaded chan bool) {
func uploadToS3(data []byte, s3Key string, contentType string, uploaded chan bool) {
md5Hash := createMD5Hash(data)
log.Infof("Uploading rendered image to: %s with md5 hash: %s", s3Key, md5Hash)
log.Infof("Uploading rendered image to: %s with md5 hash: %s content-type: %s", s3Key, md5Hash, contentType)
awsSession, err := session.NewSession()
if err != nil {
log.Error(err.Error())
Expand All @@ -130,7 +130,7 @@ func uploadToS3(data []byte, s3Key string, uploaded chan bool) {
Body: aws.ReadSeekCloser(bytes.NewReader(data)),
Bucket: aws.String(s3RenderBucket),
Key: aws.String(s3Key),
ContentType: aws.String("image/jpeg"),
ContentType: aws.String(contentType),
ContentMD5: aws.String(md5Hash),
}

Expand All @@ -147,9 +147,9 @@ func uploadToS3(data []byte, s3Key string, uploaded chan bool) {
uploaded <- true
}

func beforeResponse(imageData []byte, cachePath string) chan bool {
func beforeResponse(imageData []byte, cachePath string, contentType string) chan bool {
uploaded := make(chan bool)
go uploadToS3(imageData, cachePath, uploaded)
go uploadToS3(imageData, cachePath, contentType, uploaded)
return uploaded
}

Expand Down
Loading