Is it possible to use plugins.http.getMediaData() with a site that requires a session ID cookie? I can get the cookie beforehand but don’t know how or if its possible to do with that plugin.
For this one task I want to get an image from my web site (that requires a password if using a browser) using the session ID Cookie I have from some other method.
Thanks
Steve
I modified the current plugins.http.getMediaData() plugin and produced the following which works. Since I’m no Java expert is this the right way to do this?
I figure to make it useful for any cookie name pass an additional argument for cookie name which is easy.
Thanks
public byte js_getSmugMediaData(String SECURE_URL, String SESSION_ID)
{
ByteArrayOutputStream sb = new ByteArrayOutputStream();
try
{
URL url = new URL(SECURE_URL);
URLConnection conn = url.openConnection();
conn.setRequestProperty(“Cookie”,“SMSESS=” + SESSION_ID);
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Utils.streamCopy(bis, sb);
bis.close();
is.close();
}
catch (Exception e)
{
Debug.error(e);
}
return sb.toByteArray();
}
Cookie and PUT support will be available in the Servoy 3.5.6 Release