How to write a ruby script to handle http messages (server side)

Discussion in 'Ruby' started by Tessy Katsiampa, Dec 8, 2013.

  1. hello all,

    I used HttpUrlConnection & AsyncTask classes in Android to perform an HTTP GET and POST request in order to upload and download an image to/from a server correspondingly. I must write a Ruby script on server side to handle these requests. I managed to authenticate the user but i don't know how to store and send the image on/from the server to the Android application and also how to create a folder containing all the user data (images) on server side. Could anyone please help me with that part? I have attached the code in Ruby that i managed to write:

    require 'rubygems'
    require 'sinatra'

    use Rack::Auth::Basic, "Restricted Area" do |username,password|
    username=='user' and password=='user1'
    end

    get '/' do

    end

    post '/' do
    end



    ps:the only thing that my script needs to do is to store the image from theHTTP POST request,that the android application will perform and then to send this image back to the android application when the user performs a HTTPGET request

    Thanks in advance!
     
    Tessy Katsiampa, Dec 8, 2013
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.