paperclip

Rails 3, paperclip + S3 - Howto Store for an Instance and Protect Access

纵饮孤独 提交于 2019-12-17 17:31:58
问题 I have a Rails 3 app with paperclip, with the intent to store data on S3. In the app, Users belong to an instance. I would like the data stored across all the models per instance. And would like to prevent a user from Instance A from accessing, or being able to load data from Instance B. What's the best way to handle this? thanks 回答1: I actually just implemented authorized S3 url's in my Ruby on Rails 3 application with Paperclip . Let me share how I accomplished this. So what I did, and what

Rails: Paperclip & previews?

…衆ロ難τιáo~ 提交于 2019-12-17 17:31:44
问题 You know on some sites when you're asked to upload, say, an avatar, you click on the button, select your file, then hit OK, but before you Submit the page (as in, no record is created/updated), a little preview of the image shows up? How would I accomplish this using Paperclip for Rails? Bonus points for anyone who can point me towards a tutorial or something that might tell me how to do a Javascript crop on the image before saving the record. I haven't been able to find much on Google on the

Imagemagick issue on Lion installed with Homebrew

三世轮回 提交于 2019-12-17 16:48:09
问题 I am trying to use the Paperclip gem on a Rails project so followed the docs and first installed Imagemagick using the Homebrew recipe. I added to my model my attachment has_attached_file :screenshot This worked OK and the file uploads functioned as expected I then wanted to add thumbnails to this, so again followed the docs and added to the model has_attached_file :screenshot, :styles => { :medium => "300x300>", :thumb => "100x100>" } At this point the uploads no longer worked I check the

How to upload a Base 64 image to Rails paperclip

自作多情 提交于 2019-12-17 16:37:55
问题 I've tried a million different tutorials on the internet for how to upload a Base64 image from my iOS application to my rails app. It seems that no matter how I format the request it just won't get accepted. Does anyone know definitively how to upload a Base64 image to paperclip? I tried sending the param as JSON { "thumbnail_image": "base64_data..." } I also tried appending the data url { "thumbnail_image": "data:image/jpeg;base64,alkwdjlaks..." } I tried sending a JSON object with and

Paperclip image url

天涯浪子 提交于 2019-12-17 16:01:31
问题 Stupid question? <img alt="Phone_large" src="/system/photos/1/small/phone_large.jpg?1238845838" /> Why is "?1238845838" added to the image path? How can I get my path/url without it? 回答1: It's commonly referred to as a "cache buster". Paperclip automatically appends the timestamp for the last time the file was updated. Say you were to remove the cache buster and use /system/photos/1/small/phone_large.jpg instead. The URL wouldn't change when you changed the image and your visitors would see

Default_url in Paperclip Broke with Asset Pipeline Upgrade

孤街醉人 提交于 2019-12-17 09:22:11
问题 I'm using Paperclip and have a default_url option like this for one of my attachments: :default_url => '/images/missing_:style.png' The asset pipeline obviously doesn't like this since the directories moved. What's the best way to handle this? I have two styles for this picture (:mini and :thumb). 回答1: :default_url => ActionController::Base.helpers.asset_path('missing_:style.png') Then put the default images in app/assets/images/ 回答2: Tested only on Rails 4. To make it work in production, we

Rails + Paperclip - Update/Edit multiple images

隐身守侯 提交于 2019-12-14 03:57:57
问题 I'm building a Rails app to store products, so a product has_many images. I can upload up to 4 images when I create a New record, this is the New Action in Products controller: def new @product = Product.new 4.times { @product.images.build } end And this is the view: <%= form_for @product, :html => {:multipart => true} do |f| %> . . . . <%= f.fields_for :images do |builder| %> <% if builder.object.new_record? %> <p> <%= builder.label :image, "Image File" %> <%= builder.file_field :image %> <

Ruby on Rails / Paperclip / AWS::S3::NoSuchBucket error

二次信任 提交于 2019-12-14 03:49:26
问题 I installed the paperclip plugin and was able to use it locally. When I configured it to work with amazon S3 I keep getting the NoSuchBucket (The specified bucket does not exist) error. Paperclip documentation states that the bucket will be created if it doesn't exist but clearly something is going wrong in my case. I first insalled aws-s3 gem (v0.6.2) then also installed right_aws gem (v1.9.0) both have corresponding config.gem "aws-s3", :lib => "aws/s3" config.gem 'right_aws', :version =>

uploading file with grape and paperclip

大兔子大兔子 提交于 2019-12-14 03:42:03
问题 I'm working on a REST API, trying to upload a picture of user with: grape micro-framework paperclip gem but it's not working, showing this error rails version is 3.2.8 No handler found for #<Hashie::Mash filename="user.png" head="Content-Disposition: form-data; name=\"picture\"; filename=\"user.png\"\r\nContent-Type: image/png\r\n" name="picture" tempfile=#<File:/var/folders/7g/b_rgx2c909vf8dpk2v00r7r80000gn/T/RackMultipart20121228-52105-43ered> type="image/png"> I tried testing paperclip

Paperclip + AWS S3, Prefixing remote path with my local path

。_饼干妹妹 提交于 2019-12-14 02:32:43
问题 I'm using Paperclip with a Rails 4 app and Amazon S3 storage. On my development machine, the site is running at /Users/Jeff/Sites/example.com/web When I upload a file with Paperclip to S3, the remote path in S3 inherits my local folder structure. http://s3.amazonaws.com/example_com_bucket/Users/Jeff/Sites/example.com/web/public/assets/uploads/my_class/8/medium/some_image.png?1383060287 Why is this happening? How do I strip that part out? I tried changing the :path property but that only