Search Unity

WebGL file upload

Discussion in 'Web' started by ihsan07, Dec 3, 2017.

  1. ihsan07

    ihsan07

    Joined:
    Mar 28, 2016
    Posts:
    17
    Hi folks...
    I am trying to upload text file into WebGL Unity on runtime. Building a Javascript library and using "Send Message" function helps but I have hit a rock on that road and nobody has a solution for it yet. So I am trying to upload file with Javascript to Indexeddb where unity (Application.persistentdatapath) can access natively but I couldn't find its database name. I have tried making Unity write to console where it uploads but it has a different access system so no luck. Can someone explain me where Unity (Application.persistentdatapath) uses to save persistent data in Indexeddb?
     
  2. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    242
  3. ihsan07

    ihsan07

    Joined:
    Mar 28, 2016
    Posts:
    17
    This method uses above mentioned "send message" function to send data to unity. Problem is when text file size goes around 2mb, WebGL goes out of memory, no matter how much RAM you allocate. You can try it out yourself here and it source codes are here. That is a common problem as much as my reseach tells me. That's why I am trying for Indexeddb approach.
     
  4. ihsan07

    ihsan07

    Joined:
    Mar 28, 2016
    Posts:
    17
    Well, I found out what I did wrong. :p My method was reading contents of text file in Javascript with FileReader and sending a large string in "Send Message" function. The problem with that is there is a limit how long strings can be in browsers, therefore errors. "URL.createObjectURL" javascript method creates a blob and sends its location in string so it works. The reason that example is not working, because it tries to render contents of text file and if it is too large, it goes out of memory. I assumed Javascript "FileReader" and "URL.createObjectURL" worked same as each other.
     
  5. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    233

    Attached Files: