Re: Uploading large files from an iPAQ

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Dan (dan_at_dontspamme.com)
Date: 09/30/04


Date: Thu, 30 Sep 2004 07:35:20 -0400

Thanks Chris. BTW, do you know whether it's a good idea to flush the stream
as I'm writing the HTTP request? I'm worried that, if I don't, the buffer
might start getting big.

"Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
news:%23Au$tympEHA.2900@TK2MSFTNGP12.phx.gbl...
> Not really, and it's even harder here becasue the CF is abstracting the
> actual allocation call. If it were me, I'd just chop it into packets
around
> 1k and go that way. Heck, that even provides a progress hook for nice UI
> interaction.
>
> -Chris
>
>
> "Dan" <dan@dontspamme.com> wrote in message
> news:u6%23fhulpEHA.3716@TK2MSFTNGP10.phx.gbl...
> > Is there a way to find out how much memory you're allowed to use before
> > allocating it?
> >
> > "Chris Tacke, eMVP" <ctacke@spamfree-opennetcf.org> wrote in message
> > news:O4hbx8jpEHA.2764@TK2MSFTNGP11.phx.gbl...
> > > CE's memory model doesn't allow you to use all the "free" memory you
see
> > for
> > > heap allocations. Packetize the send.
> > >
> > > -Chris
> > >
> > >
> > > "Dan" <dan@dontspamme.com> wrote in message
> > > news:uCjFddipEHA.3068@TK2MSFTNGP15.phx.gbl...
> > > > I'm trying to upload a large binary file from an iPAQ, but am
getting
> > > > out-of-memory exceptions when I try to convert the byte array
> containing
> > > the
> > > > data to a string in order to include it in the StringBuilder object
> > which
> > > > represents the http (multipart/form-data mimetype) request. The
code
> > I'm
> > > > using to read and convert the data is below, and the exception
occurs
> in
> > > > ascii.GetString. The file is about 9mb, and I've got plenty of free
> > > memory
> > > > (according the system monitor in the iPAQ, I've got 38.64MB free
> > storage,
> > > > and 61.85MB free program memory). Does anyone have any suggestions?
> > > > Thanks...Dan
> > > >
> > > > try
> > > > {
> > > > fs = new FileStream(m_FileName, FileMode.Open, FileAccess.Read);
> > > > r = new BinaryReader(fs);
> > > > if (fs.Length > int.MaxValue)
> > > > throw new Exception("The ServletRequest library currently will
> not
> > > > upload files greater than " + int.MaxValue + " bytes. " + m_FileName
+
> "
> > > > contains " +
fs.Length
> +
> > "
> > > > bytes.");
> > > > byte[] fileContent = r.ReadBytes((int) fs.Length);
> > > > ASCIIEncoding ascii = new ASCIIEncoding();
> > > > return ascii.GetString(fileContent, 0, fileContent.Length);
> > > > }
> > > > catch (Exception e)
> > > > {
> > > > throw new Exception("Error retrieving filecontent from " +
> > m_FileName,
> > > > e);
> > > > }
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Uploading large files from an iPAQ
    ... do you know whether it's a good idea to flush the stream ... as I'm writing the HTTP request? ... > actual allocation call. ...
    (microsoft.public.pocketpc.developer)
  • Re: [PATCH 00/28] Swap over NFS -v16
    ... I'm so glad you are working with me on this and writing this in human ... there is the swap cache. ... allocation and freeing, and that wouldn't work well with slub. ... write-intent bitmaps for md/raid arrays. ...
    (Linux-Kernel)
  • Re: subroutine stack and C machine model
    ... key distinction between the language and the code. ... of the dynamic allocation system's functions, ... No. Evidence of that would be writing clearly and effectively, ...
    (comp.lang.c)
  • Re: Current tools for finding memory overwrites
    ... Fair enough, the whole problem with memory corruptions is that you can only detect a corruption in the area around a memory allocation, not the allocation itself (because it may be a valid write - the only people that can detect a corruption of data in an object are the people that wrote the object, by writing a function for integrity testing and calling it at regular intervals). ... Plus if you know where the data is getting knobbled, the analysis tab coupled with the Allocation History settings can be useful for finding references to your object that also reference parts of previously deleted objects. ...
    (microsoft.public.win32.programmer.tools)
  • Re: Thou shalt have no other gods before the ANSI C standard
    ... > The right way to handle this, of course, is to encapsulate the ... > allocation of the table and to use a symbolic range, ... Of course there is that little problem of writing, e.g., that memory ...
    (sci.crypt)