Sunday 15 August 2010

amazon s3 - Rails - Upload files direct to S3 via API -


How can I develop an API in Rail, which uploads the file directly to S3? Whatever I can get through search and using jQuery through existing gems, which can not clearly work with my API.

I am currently using a paperclip to upload, but it locks a unicorn process while the file has been uploaded.

I am working on a project that has the same requirements and used the solution I have Client (an iOS app in my case) uploads the file directly to a temporary folder in our S3 bucket.

Consistent with the paperclip attachment, its model is called asset , which we currently do:

  1. Customers S3 uploads the desired file

    li>
  2. If the upload is successful, then the client ping the file passing the details of the file location.
  3. In our case the API creates / updates the property model, the path to download the S3 file and the immediate return
  4. We will then bring and process the file to our S3 bucket to launch a delayed job process for the API server.
  5. Once the processing is finished we remove the temp file from the S3 bucket.

Here is some pseudo code

Customer upload file S3 (Our case using ASWs ISSK)

  [[BSAWSWPWPRPRRRAWWSWPRP] UploadFileTubket: URL PROGRESSBOCK: ... AgreementBLOCK: ...]  

Send details in uploaded file API

  post "server .com / api / assets "parameter: {...," s3_upload_path "= & gt; "Temp / UEA8zLE7FJ.m4v"}  

API Controller

  Create a DRF # Make arguments here @ asset.delay.fetch_s3_upload termination     property of the class has_attached_file: video ... def fetch_s3_upload url = "http: // # {ENV ['AWS_S3_HOST_NAME']} / # {ENV [ AWS_S3_BUCKET_NAME ']} / # {self.s3_upload_path} "auto .video = URI.parse (url) self.video_content_type =" video / mp4 "if self.save # s3 delete the temp file from the end of the end  

No comments:

Post a Comment