incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/3] Added Content-Disposition header for blob, so client can identify content that server is streaming
Date Tue, 07 Dec 2010 11:40:42 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 server/lib/deltacloud/helpers/blob_stream.rb |    6 +++++-
 server/server.rb                             |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/server/lib/deltacloud/helpers/blob_stream.rb b/server/lib/deltacloud/helpers/blob_stream.rb
index 45fdbef..a99e6c2 100644
--- a/server/lib/deltacloud/helpers/blob_stream.rb
+++ b/server/lib/deltacloud/helpers/blob_stream.rb
@@ -28,7 +28,11 @@ begin
       #the client guess and if they can't they SHOULD default to
       #'application/octet-stream' anyway as per:
       #http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
-      EM.next_tick { env['async.callback'].call [200, {'Content-Type' => "#{params['content_type']}",
'Content-Length' => "#{params['content_length']}"}, body] }
+      EM.next_tick { env['async.callback'].call [200, {
+        'Content-Type' => "#{params['content_type']}",
+        'Content-Disposition' => params["content_disposition"],
+        'Content-Length' => "#{params['content_length']}"}, body] 
+      }
       #call the driver from here. the driver method yields for every chunk of blob it receives.
We then
       #use body.call to write that chunk as received.
       driver.blob_data(credentials, params[:bucket], params[:blob], params) {|chunk| body.call
["#{chunk}"]} #close blob_data block
diff --git a/server/server.rb b/server/server.rb
index 076859d..a3e2289 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -516,6 +516,7 @@ get '/api/buckets/:bucket/:blob/content' do
   @blob = driver.blob(credentials, { :id => params[:blob], 'bucket' => params[:bucket]})
   params['content_length'] = @blob.content_length
   params['content_type'] = @blob.content_type
+  params['content_disposition'] = "attachment; filename=#{@blob.id}"
   BlobStream.call(env, credentials, params)
 end
 
-- 
1.7.3.2


Mime
View raw message