Page 1 of 1

Help with inserting picture reference from a web address

PostPosted: Fri Nov 24, 2006 1:08 pm
by Gordon
Hi Guys

I have been given 700 images that are stored in a web site images folder. I have created 700 records with the image name, description etc and want to show the image to the user so they can add descriptions.

In Filemaker you can use the Troi plugin to import references to the images and display them in a container field, can you do the same with Servoy and if so can anyone give me a steer in the right direction.

I have tried

globals.Image = plugins.images.getImage("http://x1.clickdigital.com/10scc/images/ddaimages/1002_7.jpg");

The path is correct and works on its own, I stcuk this onto a onLoad script to try and get them image to load into a media formatted global

and

globals.Image = plugins.file.readFile("http://x1.clickdigital.com/10scc/images/ddaimages/1002_7.jpg");

This fails as it pops up the file dialogue!

Some help on how or a steer in the right direction would be very much appreciated !

Cheers
Gordon

PostPosted: Fri Nov 24, 2006 2:04 pm
by IT2Be
would elements.elementsname.setImageURL() do it for you?

You are trying to retrieve an image by url, that will not work...

PostPosted: Sat Nov 25, 2006 1:10 pm
by cybersack
Gordon, you can simply use the data stream plugin (which you already use) to read from the URL and place it into either the media cell in the databse or a place on the Servoy server file system.

PostPosted: Sat Nov 25, 2006 1:55 pm
by Gordon
cybersack wrote:Gordon, you can simply use the data stream plugin (which you already use) to read from the URL and place it into either the media cell in the databse or a place on the Servoy server file system.


Thanks Julian - problem solved in probably the least elegant way but the clients happy and working on it !! Gordon :oops:

PostPosted: Sat Nov 25, 2006 10:59 pm
by cybersack
By 'least elegant' it sounds like you're copying it locally and then pushing it up to the Servoy server (???)

If you are, then you can instead achieve it all in one pass :)

Go to the mod_cybersack form named 'DataStream_Records_API'.
There is already a demo Servoy method which does exactly this.
It is called 'streamUrlMediaToDatabase'.
It contents are :

var serverName = currentcontroller.getServerName();
var filename = url;
var asink = (globals.async == "asynchronous");

plugins.DataStreamer.writeRecordBinaryAsStream(
mediaid, //the primary key
'mediaid', //the primary key column
'media', //the table name
'media', //the data column name
'has_media', //the data-present column name
filename, //the url to stream in
mimetype, //the mimetype which should be employed whilst loading the data in this instance (useful to override the value read from the mimetype column)
'mimetype', //the mimetype column-name
null, //passing null as the display name means that the file portion of the 'filename' attribute above will be used; you can insert a value to override this
'display_name', //the name of the column which stores the display name
asink, //should this run asynchronously ?
serverName //the server name
);


So, the argument named 'filename' accepts the input.
If your filename has a value, for example, of:
"http://x1.clickdigital.com/10scc/images/ddaimages/1002_7.jpg"

then that content wil be streamed directly into the specified database record :)