views:

98

answers:

2

Is there some way to download and store files in a specific, developer-defined location using Opera's user javascript functions?

Thanks.

+1  A: 

http://dev.opera.com/libraries/fileio/docs/overview-summary-file-io.js.dml looks like what you want.

var localDir, remoteFile;
var out = serverDir.open(remoteFile, opera.io.filemode.READ);
var in = clientDir.open(localFile, opera.io.filemode.WRITE);
var line = "";
do {
in.writeLine(line);
line = out.readLine();
} while(line);
in.close();
out.close();

The user has to change their config file to allow for these libraries.

Kateb0t
Seems like it's only for Opera Widgets, and not Opera User Scripts.
trex279
+2  A: 

Indeed, a pure JavaScript solution for this is only possible with widgets and Opera 10 and greater. It should be possible to interact with a Java applet the user has granted sufficient privileges to save files though. I've also seen a solution that used a local server which the user.js would talk to - see the "HistoryPlus" script described somewhere in this post:

http://my.opera.com/chooseopera/forums/findpost.pl?id=2669972

hallvors