Is it possible to save files to a network path? - actionscript-3

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 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.

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.

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.

Related

WebView2 Environment Exception on application hosted on a network (Requested resource is in use)

I am unable to show more than one WebView2 control in an application hosted on a network shared folder.
Let me say straight out of the bat that the solutions disused here (including Microsoft article) do not work:
WebView2 Environment Exception (Requested resource is in use)
absolutely do not fix this issue.
The application binaries is hosted on a server, with multiple users launching the application from that single location. Once one user has WebView2 displayed, another user on the network gets the exception.
As you can see in the code snippet, I am creating subfolders for each users session (this has been tested as is working as expected) :
var dataFolder = #"\\someserver\SomeApplicationFolder";
var subfolder = Guid.NewGuid().ToString();
var di = Directory.CreateDirectory(Path.Combine(dataFolder, subfolder))
var fullpath = dataFolder + #"\\" + subfolder;
var env = await CoreWebView2Environment.CreateAsync(userDataFolder: fullpath);
await webView2ReportServer.EnsureCoreWebView2Async(env);
It possible the locks happen on files in the folder "MyApplication.exe.WebView2" which is in the applications binaries folder on the single network share. But I do not want to install the binaries on each individual client's PC as this is bad practice and not desired architecture.
One way i found is to copy the exe file and run each of them on the different computers...

How to get the UNC path of a file hosted on Google Drive?

I have the drive mapped to my PC, which is no good.
I need to find the UNC path of the excel/csv files. The use case if for linking with Tableau.
I'm using windows 10.
There are several answers in this SO post, you can check some answers there.
But of all, here is the quickest:
Maybe a long way around but open a cmd window. Then do net use >
filename
Then open the filename and you can get the path:
Ex:
C:\Users\me\net use > drives.txt
Opening drives.txt
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
H: \\server\c\proj\net Microsoft Windows Network
Can copy \\server\c\prog\net from the file for your use.
Hope this helps.
You also have another choice, convert shared folder path to UNC path.

SFTP to read csv file using ssis 2008

Can we read a csv file from SFTP folder location without downloading it anywhere on local?
I can use FTP task component but it will download file locally, i want to read file from sftp itself.
Is it possible? I am using SSIS 2008.
Thanks,
Chaitanya
In general, FTP does not allow to read file directly from remote ftp server without downloading it to local folder. You have to download/copy this file to local folder for further processing.
you can delete this locally downloaded file after processing it.
But I would like to know why you decided to read it directly? Any specific reason.
There is another approach using script task. you need to write code to download the file into filestream using FTPWebRequest class. in ssis script editor.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
request.Method = WebRequestMethods.Ftp.DownloadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe#contoso.com");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
reader.Close();
response.Close();

Can't save to a JSON file on Win7 from an AIR app

I'm writing an AIR app that reads from, and writes to a local JSON file. I'm using the File and FileStream classes. It works perfectly on Mac, but on Win7 it's not saving. Does anyone know of any platform-specific issues or tips for the .writeUTFBytes() method?
file = new File(itemBase + "/manifest.json");
fileStream = new FileStream();
fileStream.open(file, FileMode.UPDATE);
fileStream.writeUTFBytes(json);
Thanks,
Wayne
On windows7 you will generally not have write permission to the "program files"-folder. You should probably set up a folder under user documents or something like that.
This might come in handy:
(from: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html)
File.applicationStorageDirectory—a storage directory unique to each
installed AIR application
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
File.desktopDirectory—the user's desktop directory
File.documentsDirectory—the user's documents directory
File.userDirectory—the user directory

AS3 - URLload local files with absoute path

I am trying to open local hard drive files inside AS3. I'm getting a security error with this code:
var soundFile:URLRequest = new URLRequest("c:\slushy.mp3");
Is it possible to URLload an absolute path on the hard drive?
Edit: so this appears to be a sandboxing issue. Drat. Is it possible to load the local file via PHP and send to flash?
PHP is a server language, so the final protocol is http.
The you must to acces by file:/// to the local file, but if you want to share the resources over Internet, you must upload your files to folder in the root of site.
By example: http://www.mysite.com/music
Then you can load the file:
var soundFile:URLRequest = new URLRequest("http://www.mysite.com/music/slushy.mp3");
Requisite: you must to create the directory "music" in server web application directory and upload the file.