Search Unity

Uploading files in Android and IOS

Discussion in 'Editor & General Support' started by Valli88, Apr 17, 2013.

  1. Valli88

    Valli88

    Joined:
    Apr 4, 2013
    Posts:
    2
    Hi,

    I'm developing an app for IOS and Android which uploading files to a server through HTTP(post/put). For images, the WWW/WWWform class works well, same for videos which are quite small < 50 mb. But for larger files >50~mb i get "out of memory"- exception.

    This is because when the app read the file it stores it in the RAM until it's uploaded.
    Code (csharp):
    1.  
    2. WWW localFile = new WWW("file:///" + localFileName);
    3.  yield return localFile;
    4.   if (localFile.error == null)
    5.             Debug.Log("Loaded file successfully");
    6.     else
    7.         {
    8.             Debug.Log("Open file error: "+localFile.error);
    9.             yield break; // stop the coroutine here
    10.         }
    11.  
    Is there any way to chunk the data or is it possible to stream it through HTTP?

    I have the possibility to upload through FTP aswell, but as far as I have understand the FTP support is limited in Unity3d.
     
  2. Valli88

    Valli88

    Joined:
    Apr 4, 2013
    Posts:
    2
    Bump!
     
    Last edited: Apr 21, 2013
  3. TomWong

    TomWong

    Joined:
    Oct 26, 2016
    Posts:
    2
    hi , did you solved the issue ? im having same issue here
     
  4. impulse9

    impulse9

    Joined:
    Sep 17, 2015
    Posts:
    12
    Same problem here :/ I can't send large files on android.
    Code (CSharp):
    1. E/dalvikvm-heap(19330): Out of memory on a 23393512-byte allocation.
    2. I/dalvikvm(19330): "Thread-1299" prio=5 tid=21 RUNNABLE
    3. I/dalvikvm(19330):   | group="main" sCount=0 dsCount=0 obj=0x42f4b640 self=0x789ccb48
    4. I/dalvikvm(19330):   | sysTid=20271 nice=0 sched=0/0 cgrp=apps handle=2106730800
    5. I/dalvikvm(19330):   | state=R schedstat=( 131573429 29466518 173 ) utm=7 stm=6 core=2
    6. I/dalvikvm(19330):   at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:~91)
    7. I/dalvikvm(19330):   at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
    8. I/dalvikvm(19330):   at com.android.okhttp.internal.http.RetryableOutputStream.write(RetryableOutputStream.java:64)
    9. I/dalvikvm(19330):   at com.unity3d.player.WWW.runSafe((null):-1)
    10. I/dalvikvm(19330):   at com.unity3d.player.WWW.run((null):-1)
    Is there a way to fix this without native extensions?
     
  5. impulse9

    impulse9

    Joined:
    Sep 17, 2015
    Posts:
    12