简体   繁体   English

使用AIR / Flex打开本地文件

[英]Open local file with AIR / Flex

I have written an AIR Application that downloads videos and documents from a server. 我编写了一个AIR应用程序,可以从服务器下载视频和文档。 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. 我已尝试使用FileReference + URLRequest类,但这会引发一个异常,它需要一个远程URL。

My last resort is just copying the file to their desktop : \\ 我的最后一招只是将文件复制到桌面:\\

You can use the new openWithDefaultApplication(); 您可以使用新的openWithDefaultApplication(); function that's available on the File class (I believe it's only available in AIR 2) File类上可用的函数(我相信它仅在AIR 2中可用)

eg: 例如:

var file:File = File.desktopDirectory.resolvePath(fileLocation);
file.openWithDefaultApplication();

This is the first release of the FluorineFx Aperture framework. 这是FluorineFx Aperture框架的第一个版本。

The framework provides native OS integration (Windows only) support for AIR desktop applications. 该框架为AIR桌面应用程序提供本机操作系统集成(仅限Windows)支持。

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. 该框架以非侵入方式扩展Adobe AIR应用程序:只需使用AIR应用程序重新分发提供的库,在运行时框架将自动挂钩到您的应用程序。

Features 特征

  • Launch native applications and documents with the provided apsystem library 使用提供的apsystem库启动本机应用程序和文档
  • Take screenshots of the whole screen with the provided apimaging library 使用提供的apimaging库获取整个屏幕的屏幕截图
  • Access Outlook contacts from an Air application with the provided apoutlook library 使用提供的apoutlook库从Air应用程序访问Outlook联系人

http://aperture.fluorinefx.com/ http://aperture.fluorinefx.com/

只有这样我才能弄清楚如何在不移动文件的情况下做到这一点并告诉用户将其传递给浏览器。

navigateToURL(new URLRequest(File.applicationStorageDirectory.nativePath + "/courses/" + fileName));

Currently adobe is not supporting opening files in there default applications. 目前adobe不支持在默认应用程序中打开文件。 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(). 但是,您可以使用FileStream并使用一些javascript来编写一个小的html文件,该文件将iframe的位置设置为该文件,然后在100ms左右后调用window.close()。 Then open that file in the browser. 然后在浏览器中打开该文件。

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 . navigateToURL(file.nativePath)不起作用,因为路径“/ users / mydirectory / ...”在应用程序沙箱之外。 AIR only allows some protocols to be opened with navigateToURL() . AIR仅允许使用navigateToURL()打开某些协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM