简体   繁体   中英

How to allow users to upload to s3, yet not use own server resources

How is it possible to allow users to upload images on a website, but the actual uploading is done completely on amazon's servers (so as to not burden your own servers with upload throughput).

Can someone explain how this is performed?

ie a user wants to upload an image, instead of streaming the file to my server, and then from my server to amazon's s3 service, it bypasses my server altogether and sends it to amazon.

You can check out these docs provided by Amazon.

You can implement the process by using a SWF uploader, or this gem .

CarrierWave can be used with CarrierWaveDirect to upload images directly to S3. This will also allow you to process the image in a background job.

However, if you want to completely eliminate both the upload and processing burden from your dynos, check out Cloudinary which is unique in that it does all image processing on their servers as well as providing storage for them.

if your using paperclip cant you just do the following?

create a s3.yml file in config

development:
  bucket: bucket-dev
  access_key_id: xxx
  secret_access_key: xxx
test:
  bucket: bucket-test
  access_key_id: xxx
  secret_access_key: xxx
production:
  bucket: bucket-pro
  access_key_id: xxx
  secret_access_key: xxx

#paperclip
has_attached_file :photo,
  :styles => {
   :thumb=> "100x100#",
   :small  => "400x400>" },
   :storage => :s3,
   :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
   :path => "/:style/:id/:filename"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM