Open rhjones opened 7 years ago
I wanted the S3 image URL to come back as part of the JSON sent after a successful upload. To do this:
Add an upload_url to the model that uses Paperclip's image.url
method to grab the upload's URL:
def upload_url
upload.url
end
And add :upload_url
to the serializer
URLs come back as http://s3.amazonaws.com/.../1478185207.png?1478185207
, which feels redundant to me. You can trim off the second timestamp by setting use_timestamp
to false
in the model:
has_attached_file :upload, :default_url => '/images/no-pattern-image.png', :use_timestamp => false
The time stamp may be used by aws to decide whether to return the file or just "no change".
@berziiii and I are thinking this might be a good repo to update and refresh since it's been used by a number of cohorts. Thoughts @gaand?
Attempting to use this for my capstone project. I have uploads working through CURL to AWS S3, and @berziiii asked me to share my notes on the steps I've taken so far. Some of these are a bit shortcut-y—focused on getting a file uploaded. I haven't attempted anything through the browser so far; I'll follow up once I have that working.
brew install ImageMagick
bundle exec rails g scaffold movie title:string
gem 'paperclip', '~> 5.0.0'
bundle install
movie_params
method in controller according to instructions in this repogem 'aws-sdk'
to gemfile and runbundle install
.env
file:S3_BUCKET_NAME
,AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,AWS_REGION
. The bucket name, access key, and secret access key are documented in the express-multer repo. The region is visible in the URL bar and looks something likeus-east-1
config/environments/development.rb
andconfig/environments/production.rb
:public/
directory.