Skip to content

Commit

Permalink
set files content type
Browse files Browse the repository at this point in the history
  • Loading branch information
ncri committed Oct 6, 2012
1 parent c4418ab commit 7797523
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ spec/gallery-jquery-fileupload
.bundle
.config
.yardoc
.idea
Gemfile.lock
InstalledFiles
_yardoc
Expand Down
14 changes: 13 additions & 1 deletion app/assets/javascripts/s3_direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ jQuery ->
fail: (e, data) ->
alert("#{data.files[0].name} failed to upload.")
console.log("Upload failed:")
console.log(data)
console.log(data)

formData: (form) ->
data = form.serializeArray()
fileType = ""
if "type" of @files[0]
fileType = @files[0].type
data.push
name: "Content-Type"
value: fileType

data

1 change: 1 addition & 0 deletions lib/s3_direct_upload/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def policy_data
["starts-with", "$utf8", ""],
["starts-with", "$key", ""],
["content-length-range", 0, @options[:max_file_size]],
["starts-with","$Content-Type",""],
{bucket: @options[:bucket]},
{acl: @options[:acl]}
]
Expand Down

0 comments on commit 7797523

Please sign in to comment.