Skip to content

Commit 7797523

Browse files
committed
set files content type
1 parent c4418ab commit 7797523

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ spec/gallery-jquery-fileupload
55
.bundle
66
.config
77
.yardoc
8+
.idea
89
Gemfile.lock
910
InstalledFiles
1011
_yardoc

app/assets/javascripts/s3_direct_upload.js.coffee

+13-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,16 @@ jQuery ->
2727
fail: (e, data) ->
2828
alert("#{data.files[0].name} failed to upload.")
2929
console.log("Upload failed:")
30-
console.log(data)
30+
console.log(data)
31+
32+
formData: (form) ->
33+
data = form.serializeArray()
34+
fileType = ""
35+
if "type" of @files[0]
36+
fileType = @files[0].type
37+
data.push
38+
name: "Content-Type"
39+
value: fileType
40+
41+
data
42+

lib/s3_direct_upload/form_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def policy_data
6565
["starts-with", "$utf8", ""],
6666
["starts-with", "$key", ""],
6767
["content-length-range", 0, @options[:max_file_size]],
68+
["starts-with","$Content-Type",""],
6869
{bucket: @options[:bucket]},
6970
{acl: @options[:acl]}
7071
]

0 commit comments

Comments
 (0)