×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    2

    upload large file to webserver from 2MB heap phone

    I have do do an app that upload the content of a storage card to
    a webserver.

    Everything is ok for small files but i get Out of Memory for files that are larger > 1,5 MB.

    I upload the file as you see below

    1) FileConnection srcroot = (FileConnection) Connector.open(path, Connector.READ);

    2) hcon = (HttpConnection) Connector.open(formUrl(), Connector.READ_WRITE);
    hcon.setRequestMethod(HttpConnection.POST);
    hcon.setRequestProperty("Cache-Control", "no-cache");
    hcon.setRequestProperty("Content-Type", "application/octet-stream");
    is = srcroot.openInputStream();
    //open output stream and send contents of byte array
    os = hcon.openDataOutputStream();

    3)
    byte[] data = new byte[bufferSize];
    for (int count; (count = is.read(data)) > 0 {
    os.write(data, 0, count);
    //os.flush();
    //Runtime.getRuntime().gc();
    }
    //os.flush()

    4) close all connections and streams


    I tried different secnarios on commented code with flush, without flush, with gc without gc with different buffer size etc...but no luck on large file (like mp3) ==> OOME ...

    What should i do to upload large files from phone with 2MB heap ?

    THX

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: upload large file to webserver from 2MB heap phone

    Hi chiovari,

    I've never directly faced this issue, but reading on these Boards it seems to be someway related to OutputStream buffering before data is actually sent.

    One workaround you could try is this (a bit tricky): use multiple connections to send small data chunks, and then let the server put them all together, rebuilding the original file.

    Hope it helps,
    Pit

Similar Threads

  1. Carbide Build PKG file to SISX - Phone says: "Can't Install"
    By mikedeklerk in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 6
    Last Post: 2009-05-19, 08:23
  2. OMA DRM media transfer using PC to Phone using USB
    By venky123 in forum Digital Rights Management & Content Downloading
    Replies: 1
    Last Post: 2008-08-13, 03:02
  3. file upload from phone to server
    By microboymega in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2007-08-23, 06:54
  4. Contacts fields order??
    By timatima in forum Symbian
    Replies: 1
    Last Post: 2007-06-08, 13:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×