views:

137

answers:

2

I was wondering if it would be possible to write a file, not to the local system, but to a connected server or other network path. Would i have to use an external php interface for this or can i entrust this to the AIR framework?

I'm pretty sure that AIR has certain security precautions to prevent this.

Thanks a bunch!

Regards

+1  A: 

What kind of network path? SMB, FTP, HTTP, WebDav, .. ?

If it's mounted on your local PC, then you should be able to write to it just like writing to any other drive or filesystem.

davr
A: 

to write a new file to a folder on a networked drive in OSX:

var targetDir:File = new File("/Volumes/Data/SomeFolder");
targetDir.createDirectory();  // ensure directory exists, create if not
var targetFile:File = targetDir.resolvePath("newFile.ext");
var fileStream:FileStream = new FileStream();
try {
    fileStream.open(targetFile, FileMode.WRITE);
    fileStream.writeBytes(byteArray);  // or what/however you want to write
    fileStream.close();
} catch (e:Error) {
    trace(e);
}

i assume for Windows you would just swap the network drive path in the first line. you should not specify a protocol (e.g. file://, smb://, etc); the format of the parameter for the File constructor is the native path (as it would appear in a terminal / command shell).

to get the path in OSX, use the Finder to navigate to the target networked folder. begin dragging the folder somewhere else, hit apple+space to open Spotlight, and continue dragging the folder into Spotlight. alternately, open a Terminal window and drag the folder into the Terminal window.

ericsco