carrierwave

carrierwave setting content_type incorrectly

孤人 提交于 2019-12-10 12:11:10
问题 I am using Carrierwave with fog storage in my Rails app, and I'm using the Carrierwave-Video and Carrierwave-Video-Thumbnailer gems to enable video uploading and thumbnail creation from the uploaded video. When I upload an mp4 file, I expect it to transcode it to mp4, create a webm version, and create two differently-sized thumbnail images (.png). Right now, all the files are successfully uploaded to Amazon S3, but the content-type is getting processed as video/quicktime for all files. This

Upload file to s3 on client side with rails, carrierwave-direct, and jquery file upload

℡╲_俬逩灬. 提交于 2019-12-10 12:08:42
问题 I keep getting a 403 when trying to upload from the client side. Is this due to not having conditions on the bucket? If I just specify the key - with no accesskey, signature, or policy - it will upload fine. Bucket policy: { "Version": "2012-10-17", "Statement": [ { "Sid": "AddPerm", "Effect": "Allow", "Principal": "*", "Action": "s3:*", "Resource": "arn:aws:s3:::example/*" } ] } CORS (open due to being local development) <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http:/

Carrierwave getting image width and height and storing it in an hstore field

醉酒当歌 提交于 2019-12-10 11:34:31
问题 My FileHandler model can allows all types of files class FileHandler < ActiveRecord::Base serialize :properties, ActiveRecord::Coders::Hstore mount_uploader :file_path, FileUploader //I'm already setting some of the file attributes here def update_file_attributes if file_path.present? && file_path_changed? self.file_name = file_path.file.filename self.file_type = file_path.file.content_type self.file_size = file_path.file.size end end //I want to get height and width here #Hstore %w

Rails4 : How do I display and edit uploaded file using carrierwave?

早过忘川 提交于 2019-12-10 11:08:24
问题 I can upload a file and save the file name in the database. But the file name doesn't appear when I edit. I'd like to: display the file name and the uploaded image when click "Edit" link in _article.html.erb. display the uploaded image in _article.html.erb. article.rb class Article < ActiveRecord::Base . . has_many :photos, dependent: :destroy accepts_nested_attributes_for :photos . . end photo.rb class Photo < ActiveRecord::Base belongs_to :article mount_uploader :image, ImageUploader

Devise + omniauth + carrierwave doesn't save facebook profile image

泪湿孤枕 提交于 2019-12-10 10:25:02
问题 I am using devise with omniauth facebook. I upload avatars for people that are not signing in with facebook with carrierwave, with the AvatarUploader. But when I try fetching the avatar from the facebook user, it does not save - user.avatar = auth.info.image does not save, and after signing in equals nil . Why is that and how can I fix it? Thanks in advance. def self.from_omniauth(auth) where(auth.slice(:provider, :uid)).first_or_create do |user| user.provider = auth.provider user.uid = auth

How can I create multiple objects in a single form in Rails 3.1?

允我心安 提交于 2019-12-10 10:09:42
问题 I have a Photo model and I want to set up a form so that a user can create multiple photos from the same form. I've watched the Railscasts #196 and 197 on nested model forms but that is more complex than what I need and deals more with forms containing multiple models, not multiple objects of the same model. Below is my code for a simple form that lets a user attach an image and create a new Photo object. I've experimented with fields_for and tried nesting but it seems overly complicated and

AWS buckets and regions

守給你的承諾、 提交于 2019-12-10 08:36:08
问题 The application is using carrierwave in conjunction with the carrierwave-aws gem. It hit snags when migrating rails versions (bumped up to 4.2), ruby versions (2.2.3) and redeployed to the same staging server. The AWS bucket was initially created in the free tier, thus Oregon, us-west-2. However, I have found that all the S3 files have the property which links to eu-west-1 . Admittedly I've been tinkering around and considered using the eu-west-1 region. However I do not recall making any

How to upload a file using AngularJs like the traditional way

▼魔方 西西 提交于 2019-12-10 04:33:45
问题 I've been tried this for days. Assuming I have a form like following: <form ng-submit="create()" class="form-horizontal" enctype="multipart/form-data"> <div class="control-group"> <label class="control-label">name : </label> <div class="controls"> <input type="text" class="input-xlarge" ng-model="message.title" /> </div> </div> <div class="control-group"> <label class="control-label">avatar : </label> <div class="controls"> <input type="file" ng-model="message.avatar" name="message[avatar]" /

How to handle a file_as_string (generated by Prawn) so that it is accepted by Carrierwave?

让人想犯罪 __ 提交于 2019-12-10 01:23:32
问题 I'm using Prawn to generate a PDF from the controller of a Rails app, ... respond_to do |format| format.pdf do pdf = GenerateReportPdf.new(@object, view_context) send_data pdf.render, filename: "Report", type: "application/pdf", disposition: "inline" end end This works fine, but I now want to move GenerateReportPdf into a background task, and pass the resulting object to Carrierwave to upload directly to S3. The worker looks like this def perform pdf = GenerateReportPdf.new(@object)

Carrierwave and amazon s3

一世执手 提交于 2019-12-10 00:06:49
问题 I am using the carrierwave gem to manage file uploads in my rails 3 app, however, I am not able to connect to my amazon s3 bucket. I have followed the instructions on the wiki yet they are not quite detailed enough, for example where do I store my s3 credentials? 回答1: Put something like this in an initializer. CarrierWave.configure do |config| config.storage = :fog config.fog_directory = 'your_bucket' config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => 'your_access_key' :aws