Hi
I am not sure what I am doing wrong I got j2me mobile app I am making and I am trying to send a picture to the server.
the pictures length is like 78,000 bytes. and then I encode it in base 64 before I sent it with j2me outputstream.
my code gets hit but the
Request.InputStream length equals 0 though. I don't understand why though.
I been playing around and found that the max I seem to be able to send is 1512 bytes in length what works out to be 2016 bytes in length in the base 64 encoding(this is the lenght of the Request.InputStream).
I am not sure why if it goes any higher then this it does not work.
I tired asking around in the j2me forums cuz I thought there might not be a contraint on how much you can send but that does not seem to be the case.
Quote:
HTTP requests are blocking streams. There is nothing at the server side until you read it. So just read the stream up to the last bit.
If you want to know the content length beforehand, you can usually find it in the request header. But you shouldn't rely on it only, because the value can be spoofed or 'forgotten' by the software used at the client side.
|
This is my code and as far as I understand I am trying to get the length.
Code:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Headers["user-agent"] == "MIDlet")
{
try
{
Stream stream = Request.InputStream;
StreamReader streamReader = new StreamReader(stream);
string test = streamReader.ReadToEnd();
byte[] raw = Convert.FromBase64String(test);
string desktop = Environment.CurrentDirectory + "\test.jpg";
File.WriteAllBytes(desktop, raw);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}