From c92cdebacdf3b3afaf8f7d143a76348ca0c94137 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 6 Feb 2014 18:08:26 +0100 Subject: [PATCH] bug #2641: Handle error on the server side when uploading a file --- src/sunstone/sunstone-server.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 6e12fff0c4..a2cf57a5d3 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -423,10 +423,15 @@ post '/upload'do tmpfile.flush else logger.error { "Unexpected rackinput class #{rackinput.class}" } - return [500, ""] + [500, ""] end - @SunstoneServer.upload(params[:img], tmpfile.path) + if tmpfile.size == 0 + [500, OpenNebula::Error.new("There was a problem uploading the file, " \ + "please check the permissions on the file").to_json] + else + @SunstoneServer.upload(params[:img], tmpfile.path) + end end ##############################################################################