|
Your continued generosity and support of FMForums is greatly appreciated. |
Howard Schlossberg
novice
Posts: 12
Loc: Los Angeles
Post Rank (AVG):
FMP: 10 Advanced OS: Windows XP
Member: FBA Skill: Expert
Certified:
FMDiSC
Tweet This Post!
|
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...
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
|
360Works offers a complete line of FileMaker plugins and add-ons targeted at FileMaker developers. |
Jesse Barnum
journeyman
Posts: 274

Loc: Atlanta, GA
Post Rank (AVG):
FMP: 11 Advanced OS: Mac OS X Snow Leopard
Member: TechNet, FBA, Platinum Skill: Expert
Certified:
FMPug
Tweet This Post!
|
In response to Howard Schlossberg
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
novice
Posts: 12
Loc: Los Angeles
Post Rank (AVG):
FMP: 10 Advanced OS: Windows XP
Member: FBA Skill: Expert
Certified:
FMDiSC
Tweet This Post!
|
In response to Jesse Barnum
Oops, sorry. Try http://www4.wppionline.com/competitions/image.php?entry=B217&sz=l&c...
|
Jesse Barnum
journeyman
Posts: 274

Loc: Atlanta, GA
Post Rank (AVG):
FMP: 11 Advanced OS: Mac OS X Snow Leopard
Member: TechNet, FBA, Platinum Skill: Expert
Certified:
FMPug
Tweet This Post!
|
In response to Howard Schlossberg
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
journeyman
Posts: 274

Loc: Atlanta, GA
Post Rank (AVG):
FMP: 11 Advanced OS: Mac OS X Snow Leopard
Member: TechNet, FBA, Platinum Skill: Expert
Certified:
FMPug
Tweet This Post!
|
In response to Jesse Barnum
Whoops, URL was cut off, never mind, it works in the browser. I'll check into it.
|
Jesse Barnum
journeyman
Posts: 274

Loc: Atlanta, GA
Post Rank (AVG):
FMP: 11 Advanced OS: Mac OS X Snow Leopard
Member: TechNet, FBA, Platinum Skill: Expert
Certified:
FMPug
Tweet This Post!
|
In response to Howard Schlossberg
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
novice
Posts: 12
Loc: Los Angeles
Post Rank (AVG):
FMP: 10 Advanced OS: Windows XP
Member: FBA Skill: Expert
Certified:
FMDiSC
Tweet This Post!
|
In response to Jesse Barnum
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
journeyman
Posts: 274

Loc: Atlanta, GA
Post Rank (AVG):
FMP: 11 Advanced OS: Mac OS X Snow Leopard
Member: TechNet, FBA, Platinum Skill: Expert
Certified:
FMPug
Tweet This Post!
|
In response to Howard Schlossberg
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
apprentice
Posts: 140

Loc: Atlanta, GA
Post Rank (AVG):
FMP: 10 Advanced OS: Cross Platform
Member: FBA, Platinum
Certified:
FMPug
Tweet This Post!
|
In response to Howard Schlossberg
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/...
http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/net...
http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/net...
We could also create a custom module that reads the stream, chunk by chunk, when the content length is not available.
|
|
Your continued generosity and support of FMForums is greatly appreciated. |
Howard Schlossberg
novice
Posts: 12
Loc: Los Angeles
Post Rank (AVG):
FMP: 10 Advanced OS: Windows XP
Member: FBA Skill: Expert
Certified:
FMDiSC
Tweet This Post!
|
In response to Valentin
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
|
360Works offers a complete line of FileMaker plugins and add-ons targeted at FileMaker developers. |