I am using the following to download images. Per Robert's suggestion, I am
going to parse the detailedresponse to check a few things.
<@assign request$URLContents '<@dom <@url location="<@var request$Image>"
waitforresults="true" detailedresponse="true" maxresultsize="128K">>'>
I put together the following to parse the xml. I was thinking that by
checking the Status Code and making sure it was 200 that that would indicate
the download was successful. Am I correct in assuming this?
In the event I am not provided with the complete file name, I want to check
the "Content-Type" so I can put the proper extension on the file when I save
it.
Is there a better way to accomplish this than the code I put together below?
Thanks
Steve Fogelson
Internet Commerce Solutions
<@assign request$Status '<@elementname object="request$URLContents"
xpath="/HTTP_RESPONSE/STATUS/*">'>
<@assign request$StatusValues '<@elementvalue object="request$URLContents"
xpointer="root().child(1).child(all)">'>
<@for start="1" stop="<@numrows array='request$Status'>">
<@if "<@var request$Status[<@currow>,1]> = 'CODE'">
<@assign request$CODE "<@var request$StatusValues[<@currow>,1]>">
<@break>
</@if>
</@for>
<@assign request$Names '<@elementattribute object="request$URLContents"
attribute="NAME" xpath="/HTTP_RESPONSE/*">'>
<@assign request$NameValues '<@elementvalue object="request$URLContents"
xpointer="root().child(all)">'>
<@for start="1" stop="<@numrows array='request$Names'>">
<@if "<@var request$Names[<@currow>,1]> = 'Content-Type'">
<@assign request$Content-TypeRow "<@currow>">
<@break>
</@if>
</@for>
<@if "<@var request$Content-TypeRow> > 0">
<@if "<@var request$NameValues[<@calc '<@var request$Content-TypeRow> +
1'>,1]> = 'image/gif'">
<@assign request$FileType "gif">
<@elseif "<@var request$NameValues[<@calc '<@var request$Content-TypeRow>
+ 1'>,1]> = 'image/jpeg'">
<@assign request$FileType "jpg">
<@elseif "<@var request$NameValues[<@calc '<@var request$Content-TypeRow>
+ 1'>,1]> = 'image/jpg'">
<@assign request$FileType "jpg">
<@elseif "<@var request$NameValues[<@calc '<@var request$Content-TypeRow>
+ 1'>,1]> = 'image/png'">
<@assign request$FileType "png">
</@if>
</@if>
----------------------------------------
To unsubscribe from this list, please send an email to [email protected]
with "unsubscribe witango-talk" in the body.