views:

142

answers:

1

Hi , i need to download a file ex:pdf from a url and store in applicationsirectory or ApplicationStorage directory , i have a code to download but its opening save dialog box to get the userinput for where to save the downloadig file ,,

this is the code iam using

downloadURL.url = urlLocation; configureListeners(file); file.download(downloadURL);

i need to download with out opening any window, and file need to be downloaded to ApplicationStorage directory ..

Thanks in advance

+1  A: 

You need the File and FileStream Classes... first load what you need as a binary URLLoader, retrieve the ByteArray, and then save it to the location you want with something like this:

var file:File = new File(File.applicationStorageDirectory.nativePath+"/myfile.jpg");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(bytes);
fileStream.close();

Where "bytes" is the bytearray you loaded...

Cay