deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 15/16] Core: Added possibility to create blob using string in blob_data
Date Thu, 19 Jul 2012 13:02:48 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/drivers/mock/mock_driver.rb |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

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
-- 
1.7.10.2


Mime
View raw message