Sha256: f984f8d5f39af097cd2ac48e131baf7390c85c92de6e179a1667748ce325d767
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
module S3Multipart class UploadsController < ApplicationController def create begin response = Upload.initiate(params) upload = Upload.create(key: response["key"], upload_id: response["upload_id"], name: response["name"]) response["id"] = upload["id"] rescue response = {error: 'There was an error initiating the upload'} ensure render :json => response end end def update return complete_upload if params[:parts] return sign_batch if params[:content_lengths] return sign_part if params[:content_length] end private def sign_batch begin response = Upload.sign_batch(params) rescue response = {error: 'There was an error in processing your upload'} ensure render :json => response end end def sign_part begin response = Upload.sign_part(params) rescue response = {error: 'There was an error in processing your upload'} ensure render :json => response end end def complete_upload begin response = Upload.complete(params) upload = Upload.find_by_upload_id(params[:upload_id]) upload.update_attributes(location: response[:location]) upload.on_complete rescue response = {error: 'There was an error completing the upload'} ensure render :json => response end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
s3_multipart-0.0.2 | app/controllers/s3_multipart/uploads_controller.rb |