Sha256: 35bdc304ebd1b905985e5b697401ed551e46ec1c5a8000dc896ecaa307bdeeba
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 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"] upload.on_begin if upload.respond_to?(:on_begin) 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 if upload.respond_to?(:on_complete) rescue response = {error: 'There was an error completing the upload'} ensure render :json => response end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
s3_multipart-0.0.4 | app/controllers/s3_multipart/uploads_controller.rb |
s3_multipart-0.0.3 | app/controllers/s3_multipart/uploads_controller.rb |