Howard Schlossberg Posted July 9, 2010 Posted July 9, 2010 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
Jesse Barnum Posted July 9, 2010 Posted July 9, 2010 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?
Howard Schlossberg Posted July 9, 2010 Author Posted July 9, 2010 Oops, sorry. Try http://www4.wppionline.com/competitions/image.php?entry=B217&sz=l&c=8x10-1&y=2010
Jesse Barnum Posted July 10, 2010 Posted July 10, 2010 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
Jesse Barnum Posted July 10, 2010 Posted July 10, 2010 Whoops, URL was cut off, never mind, it works in the browser. I'll check into it.
Jesse Barnum Posted July 10, 2010 Posted July 10, 2010 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.
Howard Schlossberg Posted July 10, 2010 Author Posted July 10, 2010 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.
Jesse Barnum Posted July 11, 2010 Posted July 11, 2010 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.
Valentin Posted July 12, 2010 Posted July 12, 2010 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.
Howard Schlossberg Posted July 12, 2010 Author Posted July 12, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now