How to access local file system from Flex web application? - apache-flex

I'm trying to access local file system from Flex web application.
I know it is pretty difficult, but I think there must be a way. Is there a way that Flex app can use AIR components or maybe web application can call some AIR module in order to choose files and upload?

There is no direct way that a web based Flex/Flash application can access AIR based APIs. They aren't built into the Flash Player, but are rather extensions built into the AIR runtime. You can't access them directly because they aren't there.
If you have an AIR app installed on the user's local machine you can, in theory, use that app as a proxy with localConnection. That way the AIR app can access the file system directly, triggered by the browser based app. I'm not sure how user interaction would work, though.
If you have server software installed on the client machine, you can trigger file processing commands from Flex using RmoteObject/HTTPService/WebService commands. This wouldn't give the user any interaction ability and is not usually practical unless you have strong control over your client machines.
Either approach would present an app installation nightmare; which almost defeats the purpose of a browser based app in the first place.

You can use FileReference's methods to ask user to select files to open (load into flash, upload into server) or save (from server or bytes from flash).

Related

Launch file on local file server from web app

Given an ASP.NET MVC intranet web app, how can I give users access to files located on a shared (mapped) drive? I don't want the browser to download a copy, I want to emulate the user navigating to the drive and opening the file.
I understand that there are security risks, and that this is not a simple task. I've considered webdav, and activex, and worst case scenario in-browser editing. BUT, I'd like to think there's a way to accomplish this.
Thoughts?
Thank you

Creating a standalone windows application from an ASP.NET website

I am developing an ASP.NET website. The users can open up the web page and work with data when they are online. But I want to make them able to work when they are offline and submit their changes later when they are online again. The offline application must be very simple to run and I don't want to develop a separate windows application for this purpose.
So I want to build an executable that when starts, first starts up a local IIS and then opens the startup page of my website (which is locally available) in the user's browser.
And of course it would be great if this executable can be installed on the user's system along with my website files, IIS and SQL Server Express all in one package.
OK I re-read your question and see that you will have local IIS and local Database installed on all client systems.
So then the solution is very simple.
The Applicaiton (main form)
Create a windows forms application.
Put a WebBrowser control and a StatusStrip control on the form.
Add two string resources named say LocalStartUrl and OnlineStartUrl, which holds the addresses of your local and online website home/startup pages.
On Form_Load, check for online internet connectivity and accordingly launch either LocalStartUrl or OnlineStartUrl in the webbrowser control. You can show messagebox and use the StatusBar to inform the user of the same.
The sync module:
The database sync module runs in the timer/separate thread and synchronizes your local database with online database in the background. It sends any unsaved changes to the server and downloads any missing data from the server to local database. You would need to control the speed of this module so that user doesn't face difficulty browsing other websites or using the application smoothly etc. It should be slow and steady and send/request only small chunks of data at a time.
When in offline mode, it just periodically checks for online connectivity at regular intervals. As soon as an internet connectivity can be found, the user is informed. If they permit, it switches over to online mode. Otherwise the user continues to work offline until the application is closed and launched again.
In online mode, the sync module syncs data to & from the online database. This doesn't affect the user because they are not connected to this database. Instead they are connected to the online website and database.
It will take efforts to streamline this approach, but ultimately it is achievable easily.
This won't be just a single task. It would be a series of task working together in sync.
Your windows application does the following:
Write the offline changes to a disk file/database etc.
Periodically check the online availability of your website/ftp site.
Whenever the website is found to be available, and there are some cached changes, submit the file to the website/ftp site.
Your server does the following:
Whenever a file is recieved, check for its validity and integrity. If found correct, put it in a specific folder.
A service on your server watches the folder and as soon as any file is found there, processes the file(s)
The service moves the file to another folder (backup) after processing.

Accessing User Application from Web Application

I have a dll i created that gets the excel object on users computer(if excel is installed) and has a handful of availalbe functions. I made a reverence to the dll in a Web Application. When I test this using the local host it works. If I deploy this on a Web Server will it still work or will it try to find the excel application on the server?
Without seeing your code I can only offer a guess, and my guess is that it will search the server and not the users computer.
You can probably use ActiveX to call Excel from the users computer, but that would only work in IE. I'm not sure who your audience is, but I needed similar functionality for the company I used to work for. For that I made a program that was installed to all users computers and then we used a custom http protocol that would open up programs on the client machine through a hyperlink. Doing it this way is cross browser compatible.

Probable issues with running flex application/swf in local mode

We are developing client application for our solution. Its a desktop client. We are using flex for same. (Although I know flex is meant for web application and air application is best suited for desktop clients, but due to some build issues we can't go for air applications). Now according to our use case we required to read file from local file system which is not allowed in flex application due to sandbox policy. To override it we had planned to use it in local mode (i.e. running from local file system instead of deploying in web container). So after running application in local mode it bypasses sandbox policy and allows to read local file. Eventually we requires remote services call (either using web services or blaze ds) also in our application. To avoid sandbox restriction for network access in local mode we are planning to explicitly grant network access permission to our flex application. So does anybody finds any issues in this approach which I may encounter ?
Thanks,
Ankur Shah
As long as you make sure to use the local-with-networking security sandbox. This will allow you to access both the local file system and the network.
You can see more about the different sandbox types here: http://livedocs.adobe.com/flex/3/html/help.html?content=05B_Security_04.html
We had to avoid any of these kinds of issues by using Air with C# WebServices and HttpServices (twas an Air GUI with C# server-side running on Windows). Although not much help to you.
Another possible solution might be to use JavaScript within Internet Explorer to access the local file system via ActiveX controls (which I hav'nt done), and then use Flex's ExternalInterface API to grab the JavaScript/Html data from within the same browser (which I have).

Sharing Adobe Flash Projector (.EXE) over Local Area Network

A forthcoming project requires that a Flash projector (.exe) be kept on a server and accessed by multiple users over network (LAN). There will be a central access database as a back-end. I am using a third party SWF2EXE (SWF Studio) product to have database functionality. I would like to know if sharing an .exe file this way is practical. I know it's not a typical client-server methodology but I can't use Server side platform like ASP due to lack of resources at the client's place. Is it likely to cause any crashes if the same .exe is launched simultaneously by network users doing a simultaneous read/write to database (mdb)?
Each computer should get a copy of the exe file, and it should be only the database which is shared. If you are on a LAN and you are using MS Access, placing the MDB file in a shared location should be fine.
You may also want to check what the concurrent user limit is for an ms access database.
Andrew

Resources