Solved

How can I check the return of objBinaryStream.Write objXMLHTTP.responseBody to see if it's what I want?

Posted on 2008-10-13
4
622 Views
Last Modified: 2012-05-05
Experts,

I have a function that I'm using to download images. I need to edit the URL so I try and get the large verion of the image URL I have. In some cases the largerURL is doesn't exists and I get an XML file returning an error.

Is it possible to check objBinaryStream.Write objXMLHTTP.responseBody to see if it's an image or an xml file?

If so how would I go about it? If not how can I cater for this problem?
0
Comment
Question by:Denisdh
  • 2
4 Comments
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 275 total points
Comment Utility
Hi, perhaps you could just use the InStr function on the responseBody to test for HTML / XML code, before writing the data to a file?

If InStr(LCase(objXMLHTTP.responseBody), "<xml") > 0 Then
   MsgBox "File is not a binary file."
Else
   objBinaryStream.Write objXMLHTTP.responseBody
End If

Regards,

Rob.
0
 

Author Comment

by:Denisdh
Comment Utility
Hey,

I've tried the following with no luck. <?xml is in the files that it downloads but this code doesn't seem to catch it.

Any other suggestions?


If InStr(LCase(objXMLHTTP.responseBody), "<?xml") > 0 Then

  Response.Write("XML File Found, no image at this URL")

End If

Open in new window

0
 
LVL 7

Assisted Solution

by:bluV11t
bluV11t earned 225 total points
Comment Utility
Hi!
I think you could check objXMLHTTP.getResponseHeader("Content-Type")
If it is xml the header should be "text/xml" and if it is image it should be somthing like "image/jpeg".
0
 

Accepted Solution

by:
Denisdh earned 0 total points
Comment Utility
I couldn't get response header to print anything for me.

In the end responseText worked.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now