Open local file with AIR / Flex
Asked Answered
G

5

12

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 : \

Ganef answered 7/8, 2008 at 17:31 Comment(0)
G
3

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));
Ganef answered 7/8, 2008 at 20:25 Comment(0)
L
13

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();
Lennyleno answered 13/7, 2010 at 0:28 Comment(0)
G
3

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));
Ganef answered 7/8, 2008 at 20:25 Comment(0)
R
2

This is the first release of the FluorineFx Aperture framework.

The framework provides native OS integration (Windows only) support for AIR desktop applications.

The framework extends Adobe AIR applications in a non-intrusive way: simply redistribute the provided libraries with your AIR application, at runtime the framework will automatically hook into your application.

Features

  • Launch native applications and documents with the provided apsystem library
  • Take screenshots of the whole screen with the provided apimaging library
  • Access Outlook contacts from an Air application with the provided apoutlook library

http://aperture.fluorinefx.com/

Raki answered 23/7, 2009 at 12:3 Comment(0)
A
0

Currently adobe is not supporting opening files in there default applications. Passing it off to the browser seems to be the only way to make it work.

You could however use a FileStream and write a small html file with some javascript that sets the location of an iframe to the file, then after 100ms or so calls window.close(). Then open that file in the browser.

Aphorize answered 14/8, 2008 at 15:32 Comment(0)
N
0

For me it's:

var request:URLRequest = new URLRequest();
request.url = file.url;
navigateToURL(request, "_blank");

The navigateToURL(file.nativePath) didn't work since the path, "/users/mydirectory/..." was outside the application sandbox. AIR only allows some protocols to be opened with navigateToURL().

Nonjuror answered 26/8, 2015 at 11:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.