Jump to content
Search Community

Downloading right to disk without loading in memory.

SudoPlz test
Moderator Tag

Recommended Posts

Hello, I need this functionallity, but I can't seem to do it by using as3. I know this might not be the correct forum to ask such a question, but I'm using LoaderMax to load my local assets anyway, so people might be experienced in these forums and answer my question..

 

What I want to do is download a few files (mp3, jpg, zip) from a remote address, and then save it right to the disk..

 

After loading everything with loader max (from the web) I end up with files loaded in memory, which I want to save on the disk..

 

var btAr:ByteArray = new ByteArray(); //initializing byte array
var snd:Sound = new mp3sound(); //this is an embeeded mp3 file !
snd.extract(btAr,int(mp3sound.length * 44.1) )  //extract the mp3 into a byte array
btAr.position = 0;
var str:String = File.applicationDirectory.nativePath;
appTempData = new File(str +"/\.\./tmp");    //temp folder of an iOs app
fr = new FileStream();
try
{
   fr.open(
    appTempData	 //  appTempData or appCache or appData or userDocs
    .resolvePath("myCache.mp3"),FileMode.WRITE);
   fr.writeBytes(btAr)
   fr.close();
}
catch(er:Error)
{
   trace("ERROR: "+er);
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...