server/lib/deltacloud/drivers/ec2/ec2_driver.rb
def create_blob(credentials, bucket_id, blob_id, data = nil, opts = {})
          s3_client = new_client(credentials, :s3)
          #data is a construct with the temporary file created by server @.tempfile
          #also file[:type] will give us the content-type
          res = nil
          # File stream needs to be reopened in binary mode for whatever reason
          file = File::open(data[:tempfile].path, 'rb')
          #insert ec2-specific header for user metadata ... x-amz-meta-KEY = VALUE
          BlobHelper::rename_metadata_headers(opts, 'x-amz-meta-')
          opts["Content-Type"] = data[:type]
          safely do
            res = s3_client.interface.put(bucket_id,
                                        blob_id,
                                        file,
                                        opts)
          end
          #create a new Blob object and return that
          Blob.new( { :id => blob_id,
                      :bucket => bucket_id,
                      :content_length => data[:tempfile].length,
                      :content_type => data[:type],
                      :last_modified => '',
                      :user_metadata => opts.select{|k,v| k.match(/^x-amz-meta-/i)}
                    }
                  )
        end
#--
# Create Blob - NON Streaming way (i.e. was called with POST html multipart form data)
#--
Create Blob - NON Streaming way
Create Blob - NON Streaming way
def create_blob(credentials, bucket_id, blob_id, data = nil, opts = {})
          s3_client = new_client(credentials, :s3)
          res = nil
          file = File::open(data[:tempfile].path, 'rb')
          BlobHelper::rename_metadata_headers(opts, 'x-amz-meta-')
          opts["Content-Type"] = data[:type]
          safely do
            res = s3_client.interface.put(bucket_id,
                                        blob_id,
                                        file,
                                        opts)
          end
          Blob.new( { :id => blob_id,
                      :bucket => bucket_id,
                      :content_length => data[:tempfile].length,
                      :content_type => data[:type],
                      :last_modified => '',
                      :user_metadata => opts.select{|k,v| k.match(/^x-amz-meta-/i)}
                    }
                  )
        end
def create_blob ( credentials , bucket_id , blob_id , data = nil , opts = { } ) s3_client = new_client ( credentials , :s3 ) res = nil file = File :: open ( data [ :tempfile ] . path , 'rb' ) BlobHelper :: rename_metadata_headers ( opts , 'x-amz-meta-' ) opts [ "Content-Type" ] = data [ :type ] safely do res = s3_client . interface . put ( bucket_id , blob_id , file , opts ) end Blob . new ( { :id => blob_id , :bucket => bucket_id , :content_length => data [ :tempfile ] . length , :content_type => data [ :type ] , :last_modified => '' , :user_metadata => opts . select { | k , v | k . match ( / ^x-amz-meta- /i ) } } ) end
Create Blob - NON Streaming way (i.e.
Create Blob - NON Streaming way ( i . e .
#data is a construct with the temporary file created by server @.tempfile #also file[:type] will give us the content-type # File stream needs to be reopened in binary mode for whatever reason #insert ec2-specific header for user metadata ... x-amz-meta-KEY = VALUE #create a new Blob object and return that
credentials
bucket_id
blob_id
data
opts