Announcement Announcement Module
Collapse
No announcement yet.
Storing recieved picture to local server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Storing recieved picture to local server

    I am to send a picture from a android phone to a local web server on my computer. How do I save it to a folder of choice? I guesse I need to write some kind of controller that takes care of the received picture and saves it?

    I am currently using Apache Tomcat/7.0.39 web server, MVC Framework through STS and my OS is Windows 7.

    Aprreciate any helt I can get!
    Code examples would be greatly appreciated.

    Best regards,
    M

  • #2
    Here is some developement of the original question which hopefully will make it more clear:

    I am to send a picture from an android phone to a local web server on my computer. I'd like to save the picture to a folder on the local server. My plan is to write some kind of controller that takes care of the received picture and saves it. So basically I think I need to create a controller that takes in a parameter (the picture) and saves it to a folder at the server. I have been searching all over and haven't yet found what I'm looking for.

    Therefore what I'd like to know is:
    How is such a controller written.




    I am currently using Apache Tomcat/7.0.39 web server, Spring MVC Framework through STS and my OS is Windows 7.

    Aprreciate any help I can get!
    Code examples would be greatly appreciated.

    Thank you,
    Max3d

    Comment


    • #3
      I suppose the picture is preferably sent as a Base64 String. I have heard something about Post requests, might that be helpful?

      Comment


      • #4
        Originally posted by Max3d View Post
        Therefore what I'd like to know is:
        How is such a controller written.
        Well, this depends on how the photo will be submitted from the phone. If using a regular POST with "multipart/form-data" encoding, there's little work for the controller to do: you'll get the photo as a MultipartFile parameter in your controller method. You can then save it to disk or whatever.

        Here's a complete example with code and all the requisites needed for it to work (Handling a file upload in a form):
        http://static.springsource.org/sprin...#mvc-multipart

        Comment


        • #5
          All right thank you!
          I've got one question though, does this work with out using a form where you have to manually upload the file?
          That is make the phone send the picture to a web server with out requireing manual work from the user (on the client side).
          I appologize if the question is unclear, I can try to clarify if needed!

          Thanks in advance!

          Comment


          • #6
            the last question is more of an Andriod SDK question.
            If you are building a generic web application that can be used from an Android phone the user would need to clidk a browse button and identify the image to upload. If you built a custom Android app you have other options, but that would something to ask in an Android forum - Here the focus is what happens when the picture gets posted to the Webserver.

            Comment


            • #7
              You can also use Apache HTTP components. It has APIs like HTTPRequest, HTTPPost etc using which you can "POST" your data to your controller. In your controller handle it accordingly as required.

              Comment

              Working...
              X