Skip to content

Commit

Permalink
Allow form helper to control content type policy
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrost committed Jun 12, 2013
1 parent ef4234f commit ab8492e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/s3_direct_upload/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def policy_data
["starts-with", "$key", @options[:key_starts_with]],
["starts-with", "$x-requested-with", ""],
["content-length-range", 0, @options[:max_file_size]],
["starts-with","$content-type",""],
["starts-with","$content-type", @options[:content_type_starts_with] ||""],
{bucket: @options[:bucket]},
{acl: @options[:acl]},
{success_action_status: "201"}
Expand Down
16 changes: 15 additions & 1 deletion spec/helpers/form_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,19 @@
s3_uploader.policy_data[:conditions].should include ["starts-with", "$key", "uploads/"]
end
end

describe "starts-with $content-type" do
it "is configurable with the content_type_starts_with option" do
content_type_starts_with = "image/"
s3_uploader = S3DirectUpload::UploadHelper::S3Uploader.new({:content_type_starts_with => content_type_starts_with})
s3_uploader.policy_data[:conditions].should include ["starts-with", "$content-type", content_type_starts_with]
end

it "is defaults to an empty string" do
s3_uploader = S3DirectUpload::UploadHelper::S3Uploader.new({})
s3_uploader.policy_data[:conditions].should include ["starts-with", "$content-type", ""]
end
end
end
end

end

0 comments on commit ab8492e

Please sign in to comment.