RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: tquill
Can you go into a bit more detail? What does your ProductCollection model and controller look like? How about your routes?
Old I know, but I'm actually wanting to do this too. Did you ever get this figured out?
After a lot of time on google, I think I finally got this addressed:
add content_type to upload_helpber.rb (fields method and policy_data method):
def fields { :key => key, :acl => @options[:acl], :policy => policy, :content_type => nil, :signature => signature, "AWSAccessKeyId" => @options[:aws_access_key_id], } end def policy_data { expiration: @options[:expiration], conditions: [ ["starts-with", "$utf8", ""], ["starts-with", "$Content-Type", ""], ["starts-with", "$key", ""], ["content-length-range", 0, @options[:max_file_size]], {bucket: @options[:bucket]}, {acl: @options[:acl]} ] } end
add the two lines above "data.submit()" in the add method in the coffeescript file
add: (e, data) -> ... $('#fileupload').append(data.context) data.form.find('#content_type').attr('name','Content-Type') data.form.find('#content_type').val(file.type) data.submit()
Did you ever figure this out? I'm looking to do the same thing.
I figured it out.
First, change the target for your form (leave the "post" though).
<div id="upload_form"> <%= s3_uploader_form post: user_url(@user), as: "user[avatar]" do %> <%= file_field_tag :file, multiple: false %> <% end %> <script id="template-upload" type="text/x-tmpl"> <div class="upload"> {%=o.name%} <div class="progress"><div class="bar" style="width: 0%"></div></div> </div> </script> </div>
In the javascript file (I converted it from coffee script) change this line in the done callback:
$.post(to, content);
to
jQuery.ajax({ type: "PUT", url: to, data: content });
Can you go into a bit more detail? What does your ProductCollection model and controller look like? How about your routes?
Old I know, but I'm actually wanting to do this too. Did you ever get this figured out?
After a lot of time on google, I think I finally got this addressed:
add content_type to upload_helpber.rb (fields method and policy_data method):
add the two lines above "data.submit()" in the add method in the coffeescript file
Did you ever figure this out? I'm looking to do the same thing.
I figured it out.
First, change the target for your form (leave the "post" though).
In the javascript file (I converted it from coffee script) change this line in the done callback:
to
Did you ever figure this out? I'm looking to do the same thing.