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
648 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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