deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [7/65] git commit: Core: Added possibility to create blob using string in blob_data
Date Fri, 20 Jul 2012 09:59:21 GMT
Core: Added possibility to create blob using string in blob_data


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/dcd627e9
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/dcd627e9
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/dcd627e9

Branch: refs/heads/master
Commit: dcd627e9e8d1db750fd7229d9532cadfd3d84cbb
Parents: 5db302c
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Jul 19 14:57:18 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Jul 20 11:59:09 2012 +0200

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/mock/mock_driver.rb |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/dcd627e9/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 72ba642..582fb6a 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -402,12 +402,22 @@ module Deltacloud::Drivers::Mock
         :id => blob_id,
         :name => blob_id,
         :bucket => bucket_id,
-        :content_length => blob_data[:tempfile].length,
-        :content_type => blob_data[:type],
         :last_modified => Time.now,
         :user_metadata => BlobHelper::rename_metadata_headers(blob_meta, ''),
-        :content => blob_data[:tempfile].read
       }
+      if blob_data.kind_of? Hash
+        blob.merge!({
+          :content_length => blob_data[:tempfile].length,
+          :content_type => blob_data[:type],
+          :content => blob_data[:tempfile].read
+        })
+      elsif blob_data.kind_of? String
+        blob.merge!({
+          :content_length => blob_data.size,
+          :content_type => 'text/plain',
+          :content => blob_data
+        })
+      end
       @client.store(:blobs, blob)
       Blob.new(blob)
     end


Mime
View raw message