How to retrieve reference to AWS::S3::MultipartUpload with ruby -
i have rails app , in controller action able create multipart upload so:
def create s3 = aws::s3.new bucket = s3.buckets["my_bucket"] key = "some_new_file_name.ext" obj = bucket.objects[key] mpu = obj.multipart_upload render json: { :id => mpu.id } end
so client has multipart upload id , can upload parts aws browser. wish create action assemble parts once done uploading. like:
def assemble s3 = aws::s3.new bucket = s3.buckets["my_bucket"] key = params['key'] bucket.objects[key].multipart_upload.complete render json: { :status => "all good" } end
this isn't working though. how retrieve reference multipartupload object or create new 1 key or id can call "complete" method on it? insight appreciated
i found method in documentation client class , got work follows:
client = aws::s3::client.new # reassemble partslist partslist = [] params[:partslist].each |key, pair| partslist.push pair end options = { :bucket_name => 'my_bucket', :key => params[:key], :upload_id => params[:upload_id], :parts => partslist } client.complete_multipart_upload(options)
Comments
Post a Comment