Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5266 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I am loading an image from a URL into a container field, using this one statement:

new URL(url)

The URL it calls is of the form:

http://www.sample.com/competitions/image.php?entry=B217&sz=l&c=8x10-1&y=2010

This works great on my local machine (inserts a JPG image), but I get FileNotFoundException errors when running it from a server-side script.

As a test, I ran the same on the server using a static url (i.e. "http://www.fmadvocate.com/square/base_elements.gif") and this works fine.

So it would seem to be something with lack of a standard image extension? And only on the FM server?

The server is using Java 1.6.0_07-b06 (as determined by a call from within ScriptMaster) with ScriptMaster 3.33.

Anything else I should look at or that I can do to my script to make this work on the server?

Thanks,

Howard Schlossberg

Posted

I get a 404 error when I try going to the URL you posted. Can you try posting a different URL that goes to a real image?

Posted

That still doesn't work for me:

apollo:My Generated Plugin jesse$ curl -I "http://www4.wppionline.com/competitions/image.php?entry=B217&sz=l&c"

HTTP/1.1 500 Internal Server Error

Content-Type: text/html; charset=UTF-8

Date: Sat, 10 Jul 2010 19:42:15 GMT

Server: Apache/2.2.3 (CentOS)

X-Powered-By: PHP/5.2.13 ZendServer/5.0

Connection: keep-alive

Posted

I found the problem - it's because the source is not returning a content-length attribute. FileMaker requires you to know the size of something in order to create a container field. ScriptMaster does not download the HTTP resource to a local disk item before giving it to FileMaker, it streams the URL contents directly into a FileMaker container field, so it can't tell beforehand how big the graphic is.

The possible solutions are 1) have the provider return the resource length as an HTTP header, or 2) have ScriptMaster download the file to a local file before handing it off to FileMaker.

I'll assume that we need option #2, since there will probably be other cases where the web server does not return a content-length attribute. I'll work on this and post here when a fix is available. In the meantime, if you can get the provider to add a content-length attribute, that will also fix the problem.

Posted

Thanks for the reply, Jesse. In our case, all images will be coming from the same provider, so I should be able to have them add the length into the header.

What I'm still curious about is why it works okay on my local machine, but not when run on the FM server. If it's going directly into the container field, then it shouldn't be an OS permissions issue. I've asked the client's IT person to upgrade the version of Java from 1.6.0_07 to something more current, but I can't find any notes as to any apparently relevant Java changes between those versions.

Posted

I don't know why it works on the local machine, that doesn't make sense to me. The good news is that I have this fixed on my development version, which will be released as ScriptMaster 4.0.

Posted

Hi Howard,

I tried the new URL and got a java.lang.NegativeArraySizeException

In this particular case, the web server does not know the length of the content, so it's returning -1 for content length, and thus the exception is thrown.

Our simple module would not work in this case, you actually have to read the incoming stream. Take a look at:

http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/io/InputStream.html

http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/net/URL.html

http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/net/URLConnection.html

We could also create a custom module that reads the stream, chunk by chunk, when the content length is not available.

Posted

Thanks for the feedback. I had the webmaster update those download pages to include content-length in the http header. The result is that, instead of the error, it now downloads image.php as a file (rather than inserting the image). When I export that file from the container to my desktop, it is not a php file when opened in a text editor...but nor is it an image when I change the extension to .jpg and try opening that in my web browser.

It all still works perfectly from my local machine (running the hosted file). I even had them update the server's plugin to 3.34 and java to 1.6.0_20, but with the same results.

I'll have to play with it some more to see if I can get anything to work.

Thanks again for your responsiveness to my posts! I really appreciate it!!!

Howard

This topic is 5266 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.