Hi all, here is a HOW TO: put files in blob and after that, open them right away
BTW this is only working in 2.0beta5
make 4 fields:
bestandspad TEXT 200
bestandsnaam TEXT 50
bestandgrootte INTEGER
media (IMAGEMEDIA)
To put files in the blob an fill the appropriate fields do this:
controller.newRecord()
filename = application.showFileOpenDialog();
if (filename)//for cancel
{
var normalizedFileName = "";
normalizedFileName = utils.stringReplace(filename,'\\','/')//make windows path like unix path
bestandspad = normalizedFileName
var idx = normalizedFileName.lastIndexOf("/");
if (idx != -1) normalizedFileName = normalizedFileName.substring(idx+1 );
bestandsnaam = normalizedFileName
media = application.readFile(filename)
bestandgrootte = plugins.file.getFileSize(filename)
}
after that, make a method that opens the files right away from out the database:
var a = bestandsnaam.lastIndexOf(".")
var b = bestandsnaam.substr(0,a)
var c = bestandsnaam.substring(a)
var filename = application.createTempFile(b,c)
application.writeFile(filename,media);
if(utils.stringMiddle(application.getOSName(),1,7) == "Windows")
{
application.executeProgramInBackground('rundll32', 'url.dll,FileProtocolHandler',filename)
}
Mabey someone can make the last method compatible with Macintosh or Linux/Unix.
Does anybody has an idea to how make a similar code to work under Linux? I tried to use the open command, but it seems to have no effect (even if I try to use it from a terminal window).
Best thing to do is ask them what application they want to open the file, and possibly substitute %s with the filename. Once they’ve answered this question once, remember it.
For example, on my unix install, images could be displayed with a variety of programs:
gimp %s
mozilla %s
firefox %s
xv %s
display %s
Personally I prefer xv or mozilla. Others prefer firefox.
Also you can do all kinds of options this way, for example:
sebster:
Best thing to do is ask them what application they want to open the file, and possibly substitute %s with the filename. Once they’ve answered this question once, remember it.
For example, on my unix install, images could be displayed with a variety of programs:
gimp %s
mozilla %s
firefox %s
xv %s
display %s
Personally I prefer xv or mozilla. Others prefer firefox.
Also you can do all kinds of options this way, for example:
sebster:
Best thing to do is ask them what application they want to open the file, and possibly substitute %s with the filename. Once they’ve answered this question once, remember it.
For example, on my unix install, images could be displayed with a variety of programs:
gimp %s
mozilla %s
firefox %s
xv %s
display %s
Personally I prefer xv or mozilla. Others prefer firefox.
Also you can do all kinds of options this way, for example: