From 60b8c2cc047e09c2c1939fffed9a4a3d20d3c7c6 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 4 Mar 2017 18:25:49 +0100 Subject: [PATCH] Set content-type for files uploaded to S3 --- src/asciinema/component/s3_file_store.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/asciinema/component/s3_file_store.clj b/src/asciinema/component/s3_file_store.clj index 478892d..3443dd0 100644 --- a/src/asciinema/component/s3_file_store.clj +++ b/src/asciinema/component/s3_file_store.clj @@ -4,7 +4,8 @@ [clj-time [coerce :as timec] [core :as time]] - [ring.util.http-response :as response]) + [ring.util.http-response :as response] + [ring.util.mime-type :as mime-type]) (:import com.amazonaws.auth.BasicAWSCredentials com.amazonaws.services.s3.AmazonS3Client [com.amazonaws.services.s3.model GeneratePresignedUrlRequest ResponseHeaderOverrides])) @@ -33,8 +34,10 @@ (file-store/put-file this file path nil)) (put-file [this file path size] - (let [path (str path-prefix path)] - (s3/put-object cred bucket path file {:content-length size}))) + (let [path (str path-prefix path) + content-type (mime-type/ext-mime-type path)] + (s3/put-object cred bucket path file {:content-length size + :content-type content-type}))) (input-stream [this path] (let [path (str path-prefix path)]