Streaming for uploading blobs to provider. Currently to create a blob we receive the blob from the client, load it into memory and then stream it up to the provider. i.e.:
client ---TEMP_FILE---> deltacloud ---STREAM---> provider Obviously this is not very useful for large blobs (e.g. an image) - especially when there can be any number of 'create blob' requests which the server would have to create temp_files for. Since Net::HTTP doesn't provide a way for us to do this 'nicely' the only way to go was with monkey patching (both to Thin::Request and Net::HTTP). Basically we hook into the 'receive' method of the thin server so as the data is read in from the client, it starts getting sent out to the provider. Also, aws gem (appoxy) doesn't provide this functionality so I do the PUT directly using (a monkey patched version of) Net::HTTP. At this point this is an ec2 specific solution - only because its rev. 1 - we will add other providers if this seems like a sane way to proceed. Also, since theres no way to do a 'put' using browser (the sinatra 'method override' stuff is not helpful here since that code kicks in way later than where I am starting to stream) I leave the original 'POST /api/buckets/:bucket' rule in there as an alternative (i.e. using the html interface and a HTTP multipart/form data upload) though this is non streaming. Most of the action happens in server/lib/deltacloud/helpers/blob_stream.rb and you can try it out using curl -H -iv --upload-file "/home/marios/Desktop/larger.txt" --user 'aws_key:aws_secret_key' http://localhost:3001/api/buckets/the_bucket_name/blob_to_be_created_name marios
