using file plugin

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

using file plugin

Postby mo_ca_mo » Mon Jan 03, 2011 5:12 pm

Hello,
I have to do a simple task: to save an image which i obtain from a scan using a pluguin.
I got the image but i couldnt save it
i use the code as follows but i couldnt solve my problem:

var srcArray = plugins.scannerPro.GetTwainSources()
var scanObject = plugins.scannerPro.QuickScan('license_key',srcArray[0],'jpg');

var image = plugins.images.getImage(scanObject);
var tempFile = plugins.file.createFile('fotoreceta','.jpg')
plugins.file.writeFile(tempFile, image)
var ok = plugins.file.copyFile(tempFile,'O:\Recetas')

'O:\Recetas' is the path where i want to save the image.

Thanks for your help
mo_ca_mo
 
Posts: 72
Joined: Wed Feb 03, 2010 8:13 pm

Re: using file plugin

Postby jcompagner » Mon Jan 03, 2011 9:02 pm

why are you using a temp file and then copy it?
why not directly create the output file you want?

edit also use the forward slash: / instead of backward \ in file paths.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: using file plugin

Postby mo_ca_mo » Tue Jan 04, 2011 2:02 pm

Problem solved:

var f = plugins.file.createFile(nombre)
if (!plugins.file.writeFile(f, scanObject))
application.output('Failed to write the file.')
var path = 'o:/Recetas/' + nombre
var ok = plugins.file.copyFile(f,path)

thank you
mo_ca_mo
 
Posts: 72
Joined: Wed Feb 03, 2010 8:13 pm

Re: using file plugin

Postby Jan Aleman » Tue Jan 04, 2011 5:27 pm

you're still writing it twice...
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Re: using file plugin

Postby mo_ca_mo » Tue Jan 04, 2011 6:31 pm

Thank you again.



var scanObject = plugins.scannerPro.QuickScan('license_key',srcArray[0],'jpg');
var f = plugins.file.createFile(path);
if (!plugins.file.writeFile(f, scanObject))
application.output('Failed to write the file.');
mo_ca_mo
 
Posts: 72
Joined: Wed Feb 03, 2010 8:13 pm


Return to Web Development

Who is online

Users browsing this forum: No registered users and 8 guests

cron