summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2012-06-28 12:28:21 +0000
committerChristoph Helma <helma@in-silico.ch>2012-06-28 12:28:21 +0000
commitc9e24988544571cce716b195d9c0f6111a3a5fb5 (patch)
treecf8d9206463bbbe8850461d767b8d70578e80c7e
parentee778e08755cda60a1f48fc0a0491e6cdfccd0c5 (diff)
multipart uploads added
-rw-r--r--lib/opentox.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/opentox.rb b/lib/opentox.rb
index 2c4f0ba..7bc8757 100644
--- a/lib/opentox.rb
+++ b/lib/opentox.rb
@@ -29,8 +29,9 @@ module OpenTox
helpers do
def parse_input
- if request.content_type == "multipart/form-data"
- @body = File.read(params[:file][:tempfile])
+ case request.content_type
+ when /multipart/
+ @body = params[:file][:tempfile].read
@content_type = params[:file][:type]
else
@body = request.body.read
@@ -64,10 +65,6 @@ module OpenTox
# Create a new resource
post "/#{SERVICE}/?" do
uri = uri("/#{SERVICE}/#{SecureRandom.uuid}")
- if @content_type =~ /multipart/
- @body = params[:file][:tempfile].read
- @content_type = params[:file][:type]
- end
FourStore.put(uri, @body, @content_type)
response['Content-Type'] = "text/uri-list"
uri