2

I've got this piece of code http://pastebin.com/VrMNuxcv which successfully uploads a file onto the server from my android.

I'd like to , however to be able to send a couple of string parameters together with it.

Could you please tell me, if possible, where exactly I need to do this in that piece of code and how?

Thanks Andreas

1
  • How do we get the parameter on the server side? Commented Apr 4, 2011 at 10:48

1 Answer 1

2

I assume that you're in control of how the server processes the upload, i.e., you wrote the server code too???

If so, I simply use custom/private request properties (i.e., prefixed x-) for some client/server code I've written. Example...

conn.setRequestProperty("x-myapp-param1", "Parameter 1 text");

Any use to you?

Sign up to request clarification or add additional context in comments.

6 Comments

I will try it and get back to you!
How do I get it on the server side? The tradiational way? i.e request.getParameter(...) ?
@kkudi: I guess it depends on which language your server code is written in. Mine is a simple HTTPListener (C#.NET) on a PC which allows me to get all header fields using Request.Headers.AllKeys. I run through them checking for "x-myapp-param1" (for example) then get the associated value.
works great! I thought the x- had to be ommitted on the server side! does it have to have the x at the front when sent from the client? Thank you so much ;-)
@kuddi: Glad to have helped. The HTTP specification allows for 'non-standard headers', i.e., private/custom data which is relevant only between clients/servers that know what the field keys/values mean. The convention is to prefix the key (at the client end) with "X-" to show that it is not part of the HTTP specification. Standard server implementations will simply ignore these but in your case (and mine) they are useful to allow our servers to look for our custom data by checking for anything prefixed "X-". I use "X-myapp-" just to add extra confirmation the data is from my client.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.