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
630 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
ID: 22707068
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
ID: 22712925
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
ID: 22713132
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
ID: 22719511
I couldn't get response header to print anything for me.

In the end responseText worked.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

15 Experts available now in Live!

Get 1:1 Help Now