Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open local file with AIR / Flex

I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.

I am looking for a way to prompt the user to Open / Save As on a local file stored in the Application Storage Directory. I have tried using the FileReference + URLRequest classes but this throws an exception that it needs a remote url.

My last resort is just copying the file to their desktop : \

like image 666
Shawn Avatar asked Aug 07 '08 17:08

Shawn


2 Answers

You can use the new openWithDefaultApplication(); function that's available on the File class (I believe it's only available in AIR 2)

eg:

var file:File = File.desktopDirectory.resolvePath(fileLocation);
file.openWithDefaultApplication();
like image 149
Chris Avatar answered Nov 15 '22 23:11

Chris


Only way I could figure out how to do it without just moving the file and telling the user was to pass it off to the browser.

navigateToURL(new URLRequest(File.applicationStorageDirectory.nativePath + "/courses/" + fileName));
like image 30
Shawn Avatar answered Nov 15 '22 21:11

Shawn