carrierwaveuploader / carrierwave-aws Goto Github PK
View Code? Open in Web Editor NEWAWS-SDK storage adapter for CarrierWave
License: MIT License
AWS-SDK storage adapter for CarrierWave
License: MIT License
hi there,
just would like to double check, I get this kind of url by setting access to be private: https://xxx.s3-ap-southeast-1.amazonaws.com/uploads/xxx/xxx/3/xxx.jpeg?AWSAccessKeyId=xxxxx&Expires=xxx&Signature=xxxxx
Is it supposed/OK to expose AWSAccessKeyId
in the url?
Config is like is:
config.aws_acl = :private
config.aws_authenticated_url_expiration = 60
Thanks!
Hey,
My company and I recently received an email about Amazon WS disabling SSL v3 on May, 20th. They are encouraging users to move to TLS instead. Do you have any clue about the compatibility of carrierwave-aws
with this, or do we need to do some work in order to get things ready for this transition ?
Thanks for your answer, I'll keep on digging about this but hope you'll be able to provide me some insight.
Hi Parker,
Please, release new gem version to rubygems.org.
We need to use new aws-sdk 2.x
Thanks
Somewhat new to Rails I had trouble making Fog work with S3 so I installed this gem. Uploading works fine but I am having trouble making my download links work. My model is Reports.
reports_controller.rb:
def download
redirect_to download_url(@report.filename)
end
<./code>
reports_uploader.rb
def download_url(filename)
url(response_content_disposition: %Q{attachment; filename="#{filename}"})
end
<./code>
carrierwave.rb
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = ENV.fetch('AWS_BUCKET_NAME')
config.aws_acl = :public_read
config.asset_host = 'http://myproject.herokuapp.com'
config.aws_authenticated_url_expiration = 600
config.aws_credentials = {
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID')}
config.aws_credentials = {
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY')
}
end
<./code>
when I click the download link I get the error "undefined method `download_url' for #ReportsController:0xb30787f4"
Thanks!
Does carrierwave-aws support getting credentials from the iam_profile like fog-aws supports?
Image uploads work when uploading through the rails app, but I have a seed file that attempts to create some records with images:
App.create( name: 'App Center', description: 'Find and install apps', url: '/app_center_/', category_id: cat_core.id, required: true, icon: File.open('./support/appicons/manage_apps.png') )
But I am getting 404 errors: No route matches [GET] "/development/images/app_icons/32/manage_apps.png"
This used to work when I used the fog gem. Any thoughts?
Hi,
What's the minimum rights policy should I give to my AWS user in order to use your gem ?
Maybe, you should document that specific point in your README. I will not give full access to my S3 buckets, and secrity aware people would do the same.
Regards,
Jules
Hi there,
I configured my rails application as below:
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = 'a-unique-name'
config.aws_acl = :public_read
config.asset_host = 'http://localhost:3000' # not sure what to put here
# config.aws_authenticated_url_expiration = 60 * 60 * 24 * 365
config.aws_credentials = {
access_key_id: 'xxxx',
secret_access_key: 'xxxx',
region: 'Singapore'
}
end
And my uploader is:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def download_url(filename)
url(response_content_disposition: %Q{attachment; filename="#{filename}"})
end
So in this configuration, files are still uploaded to my local server, rather than S3. Is there anywhere I mis configured?
Another quick question, what is config.assert_url
for?
Thanks a lot!
When I try to show the uploaded image using <%= image_tag(@idea.image) %>
inside my show.html.erb, I get uninitialized constant Aws::CF
error.
What I'm trying to do here:
Sign the image URL and display the image. I don't want to use CloudFront. I want to use S3 only.
Expected image tag HTML to something like this:
<img src="https://s3.amazonaws.com/bucket/uploads/idea/image/3/example.png?AWSAccessKeyId=AKIAJKOHTE4WTXCCXAMA&Signature=8PLq8WCkfrkthmfVGfXX9K6s5fc%3D&Expires=1354859553" />
My Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.5.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'carrierwave'
gem 'mini_magick'
gem 'aws-sdk'
gem 'aws_cf_signer'
gem 'carrierwave-aws'
group :development do
gem 'byebug'
end
My Idea model:
class Idea < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
My ImageUploader:
class ImageUploader < CarrierWave::Uploader::Base
storage :aws
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
My CarrierWave initializer:
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = '__________'
config.aws_acl = 'public-read'
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
config.aws_attributes = {
expires: 1.week.from_now.httpdate,
cache_control: 'max-age=604800'
}
config.aws_credentials = {
access_key_id: '__________',
secret_access_key: '__________',
region: 'us-east-1'
}
config.aws_signer = -> (unsigned_url, options) { Aws::CF::Signer.sign_url unsigned_url, options }
end
My questions:
aws-sdk
and aws_cf_signer
gem?fog_public = false
like what this guy mentioned here?Please help. Thanks.
For uploading to S3, the starting instructions are:
class LogoUploader < CarrierWave::Uploader::Base storage :fog
But installing the gem, and setting up an initializer CarrierWave.configure do |config| [...]
leads to the application not starting because:
Error message: uninitialized constant CarrierWave::Storage::Fog
Note: I disabled the fog gem on the basis of: "Significantly smaller footprint".
Is there currently any effort to migrate this to the new AWS SDK? If not, and this is something wanted, I'd be happy to spearhead that.
Hi there,
Thanks for your gem, it's working fine!
However, after setting up
config.asset_host = 'https://[myid].cloudfront.net'
The images are still served from the S3 bucket.
Is there another setting I forgot to do?
Thanks!
I had carrierwave+fog and my uploads in development mode saves to "public/uploads/" folder.
All that I've changed are "config.fog_credentials" to "config.aws_credentials" and "config.fog_directory" to "config.aws_bucket". All other stays the same.
But as for now in my project all files saves to "public" directory. I would like to save these files to "public/uploads/", like it was with fog.
(I have "store_dir = nil" as well, so I'm expecting it would work like it should)
So, I need to save files to "public/uploads" in development mode and not to save files in production.
What else should I change to achieve this?
hi guys,
I have configuration like below:
CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = "vendorable-#{Rails.env}"
config.aws_acl = :private
config.aws_authenticated_url_expiration = 60
config.aws_credentials = {
access_key_id: 'xxxxx',
secret_access_key: 'xxxxx',
region: 'ap-southeast-1'
}
end
So it works properly with development and staging environment. But in production environment, every time a file is uploaded, the S3 request returns 403 forbidden on the page. I have checked S3 bucket, all files have been saved in the vendorable-production.
Any suggestions are much appreciated!!
I have multiple S3 buckets for different purposes (avatars, documents etc). In the docs it says that I must configure the s3 bucket in the config file. How do I override the aws_bucket parameter so that I can use different buckets for different models?
I tried something like this:
mount_uploader :file, ProfilePictureUploader do
def aws_bucket
ENV['S3_AVATAR_BUCKET']
end
but I got an error 'ArgumentError - bucket_name may not be blank'
Any help appreciated!
Adding credentials via
config.aws_credentials = {
access_key_id: ENV['s3_access_key_id'],
secret_access_key: ENV['s3_secret'],
}
won't work outside carrierwave context. I tried calling the Elastic Transcoder api and got an AWS::Errors::MissingCredentialsError: Missing Credentials.
I tried adding the credentials once again inside the config option as the README suggested
config.aws_credentials = {
access_key_id: ENV['s3_access_key_id'],
secret_access_key: ENV['s3_secret'],
config: AWS.config({
access_key_id: ENV['s3_access_key_id'],
secret_access_key: ENV['s3_secret']
})
}
This way it worked, so I guess those options aren't being exposed to the AWS object. Is this the intended behavior?
I am only starting here because the issue cropped up after I switched from fog to carrierwave-aws. My image tags are rendering like this:
<%= image_tag(current_user.avatar.thumb.url, class: "img-circle") %>
<img class="img-circle" src="https://xxxx.cloudfront.net/images/xxx.cloudfront.net/user/9/avatar_thumb.png" alt="Avatar thumb">
but current_user.avatar.thumb.url
outputs https://xxxx.cloudfront.net/user/9/avatar_thumb.png
.
Hi there,
I've been scratching my head for a while to be able to bring a download link (for a mp3 file) to work.
I tried the redirect method but it opens the file in the browser instead of downloading it.
I also tried with send data but it copies the file first which makes it useless (it takes too much processing time).
What I want to achieve is to stream the S3 file so that the user can download it directly.
I tried to add the attribute "content_disposition: "Attachment" in my carrier wave initializer without success.
I suspect this could be achieved with the S3 object
def download_url
S3 = AWS::S3.new.buckets[ 'bucket_name' ] # This can be done elsewhere as well.
S3.objects[ self.path ].url_for( :read,
expires_in: 60.minutes,
use_ssl: true,
response_content_disposition: "attachment; filename='#{attachment_file_name}'" ).to_s
end
But I don't know how to get access to the S3 object with carrierwave-aws (and I don't even know if the above code would work).
I'm sure this is pretty straight-forward to do but I'm stuck.
Any ideas?
Thanks!
I had been having an awful time using Fog/Carrierwave and S3. After 1.5 days of work with Fog, I was able to get everything up and running in 20 minutes with your gem. Cheers!
When we upgraded our gems recently our site was broken due to a major breaking upgrade to aws-sdk
via the dependency from carrierwave-aws
. It seems to me that a change such as this should also result in a major version bump to carrierwave-aws
.
How can I configure access to cloudfront using your plugin?
As I understand I have to set up host option, but I don't see this option.
Hi there,
In my project, there is an uploader for profile image which can be public read, and another uploader for files which is private.
Currently I just configure both of them to be private in the config/initializers/carrierwave.rb
, I wonder is there a way to configure one to be private
, the other one to be public
?
Thanks a lot in advance!
The latest version is now 2.1.7 but we're locked to 2.0.x I believe in the gemspec.
Tests do pass and according to the changelog 2.1.0 shouldn't introduce any breaking changes to the public API: https://github.com/aws/aws-sdk-ruby/blob/master/CHANGELOG.md#210-2015-06-11
There are an easy way to mock this on specs? like Fog.mock!
Here's the stack trace which should help point to the file/command causing the issue:
Aws::S3::Errors::InvalidArgument:
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:18:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/param_conversion.rb:22:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/response_target.rb:18:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/seahorse/client/request.rb:70:in `send_request'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-core-2.0.48/lib/seahorse/client/base.rb:216:in `block (2 levels) in define_operation_methods'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-resources-2.0.48/lib/aws-sdk-resources/request.rb:24:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-resources-2.0.48/lib/aws-sdk-resources/operations.rb:41:in `call'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/aws-sdk-resources-2.0.48/lib/aws-sdk-resources/operation_methods.rb:19:in `block in add_operation'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/carrierwave-aws-0.6.0/lib/carrierwave/storage/aws_file.rb:56:in `store'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/carrierwave-aws-0.6.0/lib/carrierwave/storage/aws.rb:16:in `block in store!'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/carrierwave-aws-0.6.0/lib/carrierwave/storage/aws.rb:15:in `tap'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/carrierwave-aws-0.6.0/lib/carrierwave/storage/aws.rb:15:in `store!'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/carrierwave-0.10.0/lib/carrierwave/uploader/store.rb:59:in `block in store!'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
... 16 levels...
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/transactions.rb:220:in `transaction'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/transactions.rb:291:in `save!'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/activerecord-4.2.3/lib/active_record/persistence.rb:51:in `create!'
from (irb):3
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/railties-4.2.3/lib/rails/commands/console.rb:110:in `start'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in `start'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/karanjain/.rvm/gems/ruby-2.2.0@tinygive/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
And here's the gem versions being used:
carrierwave-aws (0.6.0)
aws-sdk (~> 2.0.47)
carrierwave (~> 0.7)
aws-sdk (2.0.48)
aws-sdk-resources (= 2.0.48)
aws-sdk-core (2.0.48)
builder (~> 3.0)
jmespath (~> 1.0)
multi_json (~> 1.0)
aws-sdk-resources (2.0.48)
aws-sdk-core (= 2.0.48)
Since trying to update to carrierwave-aws 0.6.0
from 0.5.0
these errors keep preventing anything from being uploaded:
unexpected value at params["Content-Disposition"]
ArgumentError (unexpected value at params["Content-Disposition"])
aws-sdk (2.0.48)
aws-sdk-resources (= 2.0.48)
aws-sdk-core (2.0.48)
builder (~> 3.0)
jmespath (~> 1.0)
multi_json (~> 1.0)
aws-sdk-resources (2.0.48)
aws-sdk-core (= 2.0.48)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
carrierwave-aws (0.6.0)
aws-sdk (~> 2.0.47)
carrierwave (~> 0.7)
hello, just moved my bucket to Frankfurt which is supposed to run only V4 authentication. Does Carrierwave-aws does support V4? I specified the region as you can see below. I'm running the this gem at the (by now) latest commit '5efab1b1a5279dcb2b9e6e716ac40c6ed6f40655'.
...
config.aws_bucket = ENV['S3_BUCKET_NAME']
config.aws_acl = :public_read
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 365
config.aws_credentials = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: 'eu-central-1'
}
Crash report
AWS::S3::Errors::InvalidRequest - The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.:
16:54:08 puma.1 | aws-sdk (1.41.0) lib/aws/core/client.rb:375:in `return_or_raise'
16:54:08 puma.1 | aws-sdk (1.41.0) lib/aws/core/client.rb:476:in `client_request'
16:54:08 puma.1 | (eval):3:in `put_object'
16:54:08 puma.1 | aws-sdk (1.41.0) lib/aws/s3/s3_object.rb:1752:in `write_with_put_object'
16:54:08 puma.1 | aws-sdk (1.41.0) lib/aws/s3/s3_object.rb:607:in `write'
When I call the delete method on my model, the model is deleted from the database but the files remain in S3.
Is deleting the file from S3 supported, or am I forgetting to do something?
Model
class HomeImage
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :image, HomeImageUploader
end
uploader
class HomeImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Process files as they are uploaded:
process :custom_resize => [1200, 400]
version :thumb do
process :custom_resize => [100, 100]
end
def extension_white_list
%w(jpg jpeg png)
end
def filename
"app_#{Zlib.crc32(model.id).to_s(36)}.#{file.extension}" if original_filename
end
def custom_resize(width, height)
manipulate! do |img|
img.resize "#{width}x#{height}"
img = yield(img) if block_given?
img
end
end
end
Controller
def destroy
if HomeImage.find(params[:id]).delete
flash[:notice] = 'Success.'
else
flash[:error] = 'Error'
end
redirect_to home_images_path
end
https://****.s3.amazonaws.com/vzbit/uploads/link/poster/18/4b4af9cc-3f4d-4ef1-878b-ad80a5866ca2.jpg?AWSAccessKeyId=AKIAJ43P3YSDPBMWFV5A&Expires=1441228284&Signature=k%2FDQ3IQjP8b1d5PkR87wc62MJug%3D
I dont see it being needed at all. How does signing the link affect performance?
My bucket is in the us-west-1 region, and it is available via special endpoint. It seems, there is no way to set the custom endpoint in the configuration. I had to monkey patch the gem:
if Settings.carrierwave.aws.endpoint.present?
class CarrierWave::Storage::AWSFile
def authenticated_url_with_endpoint(options = {})
authenticated_url_without_endpoint(
{ endpoint: Settings.carrierwave.aws.endpoint }.merge(options)
)
end
alias_method_chain :authenticated_url, :endpoint
end
end
But there is also problem with file uploads.
Please see the following error
fog gem config:
config.fog_credentials = {
:host => 's3-eu-west-1.amazonaws.com'
}
config.fog_directory = 'mybucket'
carrierwave-aws config:
config.aws_bucket = 'mybucket'
config.asset_host = 'https://s3-eu-west-1.amazonaws.com/mybucket'
Shouldn't this be kept a bit more consistent?
Hey,
I integrated the carrierwave-aws to our rails app and I its working on local, but I am getting weird errors when trying to deploy to AWS using EB CLI.
After trying to run rake db:migrate
, rake is aborted with the following error:
NoMethodError: undefined method 'aws_bucket=' for CarrierWave::Uploader::Base:Class
This is how my carrierwave.rb
file looks like:
CarrierWave.configure do |config|
config.storage = 'aws'
config.aws_bucket = ENV.fetch('S3_BUCKET_NAME')
config.aws_acl = 'private'
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
config.aws_attributes = {
expires: 1.week.from_now.httpdate,
cache_control: 'max-age=315576000'
}
config.aws_credentials = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION'] # Required
}
end
Inside my gemfile I have tried to do it with both:
gem 'carrierwave'
gem 'carrierwave-aws', '~> 1.0.0'
as well as only with the gem 'carrierwave-aws', '~> 1.0.0'
and error persists.
Any ideas on what might be causing this. I thought it might be some dependency issue but couldn't find anything.
Thanks for this carrierwave adapter. I was already using the aws-sdk gem so this lightweight add-on to carrierwave is much nicer than having to use fog.
I'd like to use a cloudfront asset host to serve content, but it looks like this is currently only possible via the public_url
method and a public_read
acl. I have some private content I'd like to serve.
Is it possible to serve private content and also use cloudfront? I'm not super familiar with cloudfront but from what I've read it seems like it should be possible. I came across this post related to fog: http://stackoverflow.com/questions/19458004/cloudfront-carrierwave
Any help would be greatly appreciated!
If you want a link with content disposition set to "attachment" but the ACL is public_read it will not generate a proper link for that but instead just link straight to the document.
I set up a bucket policy to require that files uploaded be server-side encrypted. I got it all to work without the bucket policy, but here I'm needing to pass header and value.
CarrierWave.configure do |config|
...
config.aws_attributes = {'x-amz-server-side-encryption' => "AES256"}
...
end
It doesn't seem to work and I'm not finding any documentation to the contrary. Is there something I'm missing?
I'm attempting to use carrierwave_backgrounder with carrierwave-aws and am running into the following error: AWS::S3::Errors::NoSuchKey: No Such Key error on store
Here is a full stack trace:
AWS::S3::Errors::NoSuchKey: No Such Key
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-1.49.0/lib/aws/core/client.rb:375:in `return_or_raise'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-1.49.0/lib/aws/core/client.rb:476:in `client_request'
(eval):3:in `head_object'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-1.49.0/lib/aws/s3/s3_object.rb:293:in `head'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/aws-sdk-1.49.0/lib/aws/s3/s3_object.rb:325:in `content_type'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-aws-0.4.1/lib/carrierwave/storage/aws.rb:46:in `content_type'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-aws-0.4.1/lib/carrierwave/storage/aws.rb:113:in `uploader_write_options'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-aws-0.4.1/lib/carrierwave/storage/aws.rb:77:in `store'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-aws-0.4.1/lib/carrierwave/storage/aws.rb:16:in `block in store!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-aws-0.4.1/lib/carrierwave/storage/aws.rb:15:in `tap'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-aws-0.4.1/lib/carrierwave/storage/aws.rb:15:in `store!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/store.rb:59:in `block in store!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/store.rb:58:in `store!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:375:in `store!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:207:in `store_file!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/carrierwave_backgrounder-0.4.1/lib/backgrounder/orm/base.rb:89:in `store_file!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:424:in `block in make_lambda'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:221:in `call'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:221:in `block in halting_and_conditional'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:215:in `call'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:86:in `call'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:86:in `run_callbacks'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/callbacks.rb:302:in `create_or_update'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/persistence.rb:125:in `save!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/validations.rb:57:in `save!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/transactions.rb:273:in `block in save!'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:199:in `transaction'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/transactions.rb:208:in `transaction'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
/Users/donald/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.5/lib/active_record/transactions.rb:273:in `save!'
FYI the value of new_file inside the content_type method inside storage/aws.rb:46 is as follows:
#<CarrierWave::Storage::AWS::File:0x007fc88e4a14c0 @uploader=#<DeviceIdentifierListUploader:0x007fc8969c9f08 @model=#<DeviceIdentifierList id: 18, name: "aertaeryaeryaertae", user_id: -1, latest_sha1: nil, created_at: "2014-08-21 13:39:41", updated_at: "2014-08-21 13:39:41", customer_id: 2, file: "ifa_list_example_file.csv", file_processing: false, file_tmp: nil, state: "processing">, @mounted_as=:file, @cache_id="1408628381-32549-8749", @filename="ifa_list_example_file.csv", @original_filename="ifa_list_example_file.csv", @file=#<CarrierWave::Storage::AWS::File:0x007fc88e4a14c0 ...>, @versions={}, @upload_directory="/Users/donald/Projects/poblano/public/uploads/tmp/1408628381-32549-8749", @storage=#<CarrierWave::Storage::AWS:0x007fc894e5a0d8 @uploader=#<DeviceIdentifierListUploader:0x007fc8969c9f08 ...>, @connection=<AWS::S3>>>, @connection=<AWS::S3>, @path="uploads/device_identifier_list/file/18/ifa_list_example_file.csv">
Any help would be greatly appreciated
Hi there,
with an uploader mounted on a field urls_file
, setting this field to nil
has confusing behavior.
model.urls_file = nil
sets a weird path:
@file=#<CarrierWave::Storage::AWSFile:0x0000000be93210
...
@path="uploads/model/urls_file/558c1d33af53dbc48000002f/_old_"
...
Moreover a model.urls_file.present?
now returns true
.
This differs from other carrierwave storages (like filestorage).
Hi, how would I set aws_attributes specifically for each version. In one case I would like to overwrite content_type.
Hi there,
Im consistently getting this error:
'The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.'
when using your gem alongside carrier wave on my localhost.
I have a stackoverflow link here with details explaining this issue in full.
http://stackoverflow.com/questions/32619941/s3-carrierwave
Thanks
Hi there,
I am generating some reports in my project, which needs to have links to point to the pdf files uploaded to the s3.
As the aws credentials I am using will expire the file link after a while(which means I cannot use those static links in the report), so I wonder is there any simple set up could support this:
www.example/documents/1
https://xxx.s3-ap-southeast-1.amazonaws.com/uploads/xxx/xxx/3/xxx.jpeg?AWSAccessKeyId=xxxxx&Expires=xxx&Signature=xxxxx
Thanks!
Can we get a version bump? Would be nice to not have to track master to get commits.
Is there a way I can set the expires header on files uploaded to s3 using carrierwave-aws
Hello,
Uploaded files with my carrierwave uploader have some extra parameters that i want to hide
Is there a way to hide them ? of course i don't like the idea of having the AWSAccessKeyId on all of the filenames ....
thanks !
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
Hi, I´m getting this error when running my tests.
Failure/Error: get :shared, { format: :json, id: image.id, token: image.token }
ActionView::Template::Error:
uninitialized constant Aws::CF
# ./config/initializers/carrierwave.rb:29:in `block (2 levels) in <top (required)>'
# /Users/nicolaiseerup/.rvm/gems/ruby-2.2.3/bundler/gems/carrierwave-aws- 900b3a2b2907/lib/carrierwave/storage/aws_file.rb:64:in `call'
# /Users/nicolaiseerup/.rvm/gems/ruby-2.2.3/bundler/gems/carrierwave-aws-900b3a2b2907/lib/carrierwave/storage/aws_file.rb:64:in `signed_url'
# /Users/nicolaiseerup/.rvm/gems/ruby-2.2.3/bundler/gems/carrierwave-aws-900b3a2b2907/lib/carrierwave/storage/aws_file.rb:81:in `url'
This is my config file:
CarrierWave.configure do |config|
config.storage = Rails.env.test? ? :file : :aws
# config.storage = :aws
config.aws_bucket = "#{ ENV['S3_DIRECTORY'] }#{ Rails.env }"
config.aws_acl = 'private'
config.enable_processing = false if Rails.env.test?
# Optionally define an asset host for configurations that are fronted by a
# content host, such as CloudFront.
config.asset_host = ENV['CDN_ASSET_HOST']
# The maximum period for authenticated_urls is only 7 days.
config.aws_authenticated_url_expiration = ENV['ASSETS_EXP_TIME'].to_i + 60
# Set custom options such as cache control to leverage browser caching
config.aws_attributes = {
expires: 1.week.from_now.httpdate,
cache_control: 'max-age=604800'
}
config.aws_credentials = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION']
}
# Optional: Signing of download urls, e.g. for serving private
# content through CloudFront.
config.aws_signer = -> (unsigned_url, options) { Aws::CF::Signer.sign_url unsigned_url, options }
end
Thanks for developing this gem. I've been using it to upload video files onto my Amazon S3 account. Recently, I've tried to upload videos from my iPhone browser (Chrome and Safari) to Amazon as well but for some reason, the size of the uploaded file in my S3 bucket is 0 bytes (yes, the name of the file is successfully created).
Can you tell me Carrierwave is capable of uploading files stored on iOS to Amazon S3? I'm wondering if the contents of the file aren't uploading because Carrierwave isn't able to upload the file in a temporary directory on iOS (the way it does for for desktop browsers) in order to validate the file prior to sending to Amazon. Thanks!
I'm trying to get up and running with carrierwave-aws, but I hit this problem early on.
ArgumentError ( is not a recognized storage provider)
I'm pretty confused about what (if anything) needs to change in avatar_uploader.rb. Right now it still has:
storage :fog
include CarrierWave::MimeTypes
process :set_content_type
It seems like having storage type :fog would be wrong, but I wasn't sure what else to use, and you said things ran the same way.
How can I get my program to recognize carrierwave-aws?
I first searched for a solution which pointed me to this #12 and then I added that to my initializer:
config.aws_attributes = {
'cache_control' => 'public,max-age=315576000',
'expires' => 1.year.from_now.httpdate
}
But my uploaded images don't have these attributes. I'm using:
carrierwave-aws (0.3.2)
aws-sdk (>= 1.8.0)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.