paperclip

Rails convert Paperclip directory structure to Carrierwave

你离开我真会死。 提交于 2019-12-08 05:53:38
问题 I was using the Paperclip gem: https://github.com/thoughtbot/paperclip I'm now using Carrierwave: https://github.com/carrierwaveuploader/carrierwave My production website is currently using Paperclip. I'm going to be updating the production website to use Carrierwave. The folder structure for uploads in Paperclip differs from Carrierwave. I'm also using Amazon S3 to store uploads. I'm wondering if there's a way to convert my production files uploaded with Paperclip to Carrierwave. For example

Titanium + Rails + Paperclip === NULL values?

独自空忆成欢 提交于 2019-12-08 05:48:56
问题 EDIT: The real question was whether or not you can use a JSON http header, and how to format an XHR send of a file to a Rails application. 回答1: In order to get the file there successfully, you might need to assemble a request with a content-type of "multipart/form-data". Here's a page I found that seems to have the right kind of information to send you in the right direction: http://www.smokycogs.com/blog/titanium-tutorial-how-to-upload-a-file-to-a-server/ 来源: https://stackoverflow.com

Access Paperclip image before it's uploaded to S3

谁说胖子不能爱 提交于 2019-12-08 04:37:48
问题 My Rails app uploads images to S3 with Paperclip. I want to "intercept" the image before it is sent to S3, convert it to base64, and send it to a third-party API. How can I access the image before it gets uploaded by Paperclip to S3? This would be quicker than reading the file from S3 afterwards, and then sending it to the third-party API. 回答1: Try this class Model < ActiveRecord::Base has_attached_file :image before_save :send_image private def send_image image.queued_for_write[:original] #

Paperclip::Errors::NotIdentifiedByImageMagickError in Rails 4

别说谁变了你拦得住时间么 提交于 2019-12-08 04:26:10
问题 There is the following model: class Picture < ActiveRecord::Base belongs_to :business has_attached_file :image, styles: { medium: "640x260>" } validates_attachment :image, content_type: { :content_type => /\Aimage\/.*\Z/ } end Also I've installed 'imagemagick' using brew (I use Mac OS). But when I was trying to execute the following code @picture = business.pictures.build(picture_params) @picture.save def picture_params params.require(:picture).permit(:image) end I got the following error: An

How to save a Canvas via Paperclip

半腔热情 提交于 2019-12-08 02:43:40
问题 I have been working with two approaches, but the goal is just to save the canvas via Paperclip. First approach Canvas to Base64 and then add base64 to params with ajax $(document).on('click', '#save_canvas', function() { var base64Data = canvas.toDataURL() $.ajax({ type: "POST", url: "pictures/", data: { base64: base64Data }, success: function(post){ console.log('success') }, error: function(post){ console.log(this) } }) }) Access params[:base64] via Paperclip.adapters_io def create @picture

Multiple Images for Multiple Models - Paperclip, Rails

让人想犯罪 __ 提交于 2019-12-08 02:01:30
问题 I have four models, let's call them Cars and Houses. Users can have multiple cars, and multiple houses. Cars and Houses belong to Users. I'd like users to be able to upload multiple photos of their cars, and multiple photos of their houses, and from what I've read this means creating a new model called 'Photos'. Is it possible for two different models to both have_many Photos, and for Photos to belong_to more than one model? I'm using Ruby 2.0.0 and Rails 4. Sketch / PseudoRuby User has_many

Upgrading 1.8.7 to 1.9.3, paperclip s3 upload not working

守給你的承諾、 提交于 2019-12-08 01:36:20
问题 While i am migrating from Ruby 1.8.7 to 1.9.3, facing one issue on Paperclip photo upload. We have Paperclip configured, with s3 as a store. It works fine when i run rails server using 1.8.7, but its not uploading the file (without any error) with 1.9.3. Please have a look at configuration and log. paperclip config: has_attached_file :pic, :styles => { :thumb => "100x100#", :one => "118x100#", :two => "222x149#", :three => "460x345#", :popup => "480x360#" }, :storage => :s3, :s3_credentials =

Rails3, S3, Paperclip Attachment as it's own model?

感情迁移 提交于 2019-12-07 21:40:11
问题 So, I'm working on an app where users can upload and manage photos with a bunch of industry specific metadata attached to them. The Photo model has all this metadata in it, and I'm using Paperclip to attach the actual image file to the model and store the images on Amazon S3. The user interaction currently works like this: A user clicks "Add Photo" and is taken to the "New Photo" page where he is presented a form. The first thing on the form is a file chooser. The user selects a file. Beneath

Rails 4: Multiple image upload using paperclip

夙愿已清 提交于 2019-12-07 18:35:46
问题 I'm looking to upload multiple images to my 'locations' model. I've called the images model 'assets'. One location has multiple assets. I'm also using paperclip to handle the uploads and nested_form to allow selecting multiple assets. Weirdly, the locations hash looks to be passing the variables correctly, but they don't appear to be being picked up by the assets model. Any help would be great! Location model class Location < ActiveRecord::Base has_many :location_post has_many :posts,

Amazon S3 only accepting files with no spaces, no numbers in the title?

两盒软妹~` 提交于 2019-12-07 16:40:47
问题 This is an odd question, but only commensurate with the strange behavior I'm seeing. My app is Rails 3/Paperclip/S3. Symptoms: All images are uploading regardless of their title. When uploading a .pdf or .doc, if the title has no spaces like my_doc.pdf, it uploads fine. When uploading a .pdf or .doc with spaces, such as My Doc.pdf, it fails, either with error broken pipe or by the file silently failing to upload to S3. When uploading a .pdf or .doc with numbers, such as mydoc20.pdf, it also