Help with inserting picture reference from a web address

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Help with inserting picture reference from a web address

Postby Gordon » Fri Nov 24, 2006 1:08 pm

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
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Postby IT2Be » Fri Nov 24, 2006 2:04 pm

would elements.elementsname.setImageURL() do it for you?

You are trying to retrieve an image by url, that will not work...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby cybersack » Sat Nov 25, 2006 1:10 pm

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.
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am

Postby Gordon » Sat Nov 25, 2006 1:55 pm

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:
Gordon McLean
Click Digital Media Ltd
SAN Developer
www.clickdigital.com
User avatar
Gordon
 
Posts: 265
Joined: Thu Mar 17, 2005 8:05 pm
Location: UK

Postby cybersack » Sat Nov 25, 2006 10:59 pm

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 :)
http://www.cybersack.com/
Cybersack Java Beans and Plugins
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am


Return to How To

Who is online

Users browsing this forum: No registered users and 4 guests