fog

How do I rename a file with Fog?

蹲街弑〆低调 提交于 2019-12-04 18:05:20
问题 I have a rails 3.2 app. Using fog to store files in S3. I would like to write a script to rename all of the files that have been uploaded. I can't seem to find any fog documentation in this area. Is this possible with fog? Do I need another gem? 回答1: The bad news is you need to do a get/create/destroy foo = bucket.files.get 'foo' bar = bucket.files.create :key => 'bar', :body => foo.body foo.destroy The good news is if you're doing it from ec2 in the same region it will probably happen as

undefined method `fog_host='

江枫思渺然 提交于 2019-12-04 17:29:37
问题 When i'm trying to run my application, i'm getting the following error: config/initializers/carrierwave.rb:4: undefined method `fog_host=' for CarrierWave::Uploader::Base:Class (NoMethodError) Here is my initializers/carrierwave.rb file: CarrierWave.configure do |config| config.storage = :fog config.fog_directory = 'media.domain.pl' config.fog_host = 'http://s3-eu-west-1.amazonaws.com/media.domain.pl' config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => '***', :aws_secret

How to upload custom S3 metadata with Carrierwave

微笑、不失礼 提交于 2019-12-04 14:37:22
I want to add Content-Disposition header to a file I'm uploading with carrierwave (it's not an option to do it afterwards via query param in the URL). Is there something I can add to the AttachmentUploader model that would help me accomplish this, before the file is uploaded? Thanks! You can set attributes either globally in your Carrierwave config - CarrierWave.configure do |config| config.fog_attributes = {'Content-Disposition' => ...} end or you can define it on the uploader class itself def fog_attributes {'Content-Disposition' => ...} end and the method on the uploader can use data

Rails image_tag rotates image

北战南征 提交于 2019-12-04 13:11:38
I am using Amazon's S3 for image storage with carrierwave and fog configured. The images seem to store correctly however when I have a 'portrait' image (smaller width than height) it is not displaying correctly, but rather rotating the image on its side. Any pointers in the right direction would be much appreciated! uploaders/image_uploader.rb class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::RMagick include Sprockets::Helpers::RailsHelper include Sprockets::Helpers::IsolatedHelper storage :fog include CarrierWave::MimeTypes process :set_content_type process :resize_to

howto: Basic setup of carrierwave [Heroku and S3]

人走茶凉 提交于 2019-12-03 16:09:37
I have an S3 bucket for production and development. I have done my research and came across this post but my current config does not work as expected. I get the following exception (below) locally and I get no file uploads to my S3 bucket from my heroku app: is not a recognized storage provider Extracted source (around line #3): 1: 2: <p><%= user.name %></p> 3: <%= image_tag user.avatar.url %> 4: <%= link_to 'Show', user %> 5: <%= link_to 'Edit', edit_user_path(user) %> 6: <%= link_to 'Destroy', user, confirm: 'Are you sure?', method: :delete %> However When I set storage :file inside of the *

Ruby - Append content at the end of the existing s3 file using fog

人盡茶涼 提交于 2019-12-03 15:31:50
How to append text in an existing or newly created file in S3. I am using fog and I have following code require 'fog' file = "abc.csv" bucket = 'my_bucket' storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => 'XXXXXXXX', :aws_secret_access_key => 'YYYYYYYY') dir = connection.directories.new(:key => bucket) # no harm, if this bucket already exists, if not create one buffer = ["big_chunk1", "big_chunk2", "big_chunk3", "big_chunk4", "big_chunk5"] # I need help after this line. No changes above. buffer.each do |chunk| # this will not work as it will not append text below the

undefined method `fog_host='

半世苍凉 提交于 2019-12-03 10:30:12
When i'm trying to run my application, i'm getting the following error: config/initializers/carrierwave.rb:4: undefined method `fog_host=' for CarrierWave::Uploader::Base:Class (NoMethodError) Here is my initializers/carrierwave.rb file: CarrierWave.configure do |config| config.storage = :fog config.fog_directory = 'media.domain.pl' config.fog_host = 'http://s3-eu-west-1.amazonaws.com/media.domain.pl' config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => '***', :aws_secret_access_key => '***', :region => 'eu-west-1', } end I have carrierwave and fog included in my Gemfile and it

Save files using paperclip via API

微笑、不失礼 提交于 2019-12-03 07:48:49
I'm using paperclip to manage uploads, backed onto S3 via Fog. It works well. I'm trying to take attachments out of emails and save them via paperclip (using the same model etc). Email are parsed by an external service and POSTed to my app, including the attachments. I'm receiving the file itself fine, but I can't work out how to save it using paperclip. The post gives me an object of type ActionDispatch::Http::UploadedFile . I took a look at the below, but this involves creating a new File object. I'm not sure this is what I want... How should I do it? Saving files using Paperclip without

Heroku timeout when uploading big file to s3

久未见 提交于 2019-12-03 05:57:17
I got a problem with my application based on RefineryCMS 1.0.8 deployed on heroku. Heroku have a request timeout of 30 seconds. When uploading a file > 4MO through the RefineryCMS admin, it will sometimes take more than 30 seconds to perform the request (mostly because of the time needed to upload the file to s3). In this case, the dyno will be "frozen" and unresponsive for around 30 minutes (every request during this time end up by a H12 Error request timeout). This behaviour is exactly what describe christos in the last message in this discussion From this other discussion and the heroku

AWS S3 Disabling SSLv3 Support

人盡茶涼 提交于 2019-12-03 02:57:19
问题 We received an email from AWS that basically says 'S3 is disabling SSLv3 Support, access will be cut-off in 15 days'. They then listed some buckets we have (one in production) that are 'currently accepting request from clients that specify SSLv3'. The full email is here, and other AWS users seem to have received one too: https://gist.github.com/anonymous/4240c8af5208782c144c My question is how do we test for this scenario, and what do we need to do to prepare for this cut-off date? We use