Opening external documents

I have a database with a media-field in which I store all kind of documents (pdf’s, images, word documents etc.).

In FileMaker you can double-click on the document and he will recognize the application he needs to open without writing any methods.

I understand that Servoy doesn’t has this feature yet.

Is anybody there with a suggestion how to do that with a method?

Will this feature be available in Servoy 4.0?

Try this

var vFilePath = "path to the file"
if (utils.stringMiddle(application.getOSName(), 1, 7) == 'Windows') {
	application.executeProgram('rundll32', 'url.dll,FileProtocolHandler', vFilePath)
} 
else if (utils.stringMiddle(application.getOSName(), 1, 3) == 'Mac') {
	application.executeProgram('open', vFilePath);
}
var vFilePath = "path to the file"

I guess I don’t have a path, my documents are stored in the database, not only linked. I do this to be enable the web-client to download them.

If you have stored your document in a blob, then you need to write it to disk first. See the file plugin methods. The file plugin allows you to create a temp file. That file’s path can be used then…

I’ve tried the writeFile plugin, but I’m having some problems.

var filePath = 'MyHardisk/MyFolder/test.doc'
var success = plugins.file.writeFile(filePath,forms.action_list.act_document);
if (success)
{ plugins.dialogs.showInfoDialog('Export', 'File OK', 'OK');
}

I get no warnings, the dialog says “File OK” but I can’t find any file in MyFolder.

What am I doing wrong?

irenem:
I’ve tried the writeFile plugin, but I’m having some problems.

var filePath = 'MyHardisk/MyFolder/test.doc'

var success = plugins.file.writeFile(filePath,forms.action_list.act_document);
if (success)
{ plugins.dialogs.showInfoDialog(‘Export’, ‘File OK’, ‘OK’);
}




I get no warnings, the dialog says "File OK" but I can't find any file in MyFolder.

What am I doing wrong?

I think, the file hasn’t been created yet. First create the File then write into that.

var filePath = 'MyHardisk/MyFolder/test.doc'
var file = plugins.file.createFile(filePath);
var success = plugins.file.writeFile(file,forms.action_list.act_document);
if (success)
{ plugins.dialogs.showInfoDialog('Export', 'File OK', 'OK');
}

Than you ars,

I’ve tried your suggestion. No go, the result is the same.

Your path looks strange. What system are you on? On windows, it should look something like C:.…, and on the Mac I think it should be /Volumes/myHardDisk/…

I’m on a Mac. You are right, it works heavenly now.

Thank you