472,101 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,101 software developers and data experts.

How to save byte stream as binary document

Hi,

A site Im working with has an API that allows one to retrieve files.
The file is a Word doc sent as a byte stream.

url="blah.asp?fileid=777777"
set oXMLHTTP=server.CreateObject("MSXML2.ServerXMLHTTP .4.0")
oXMLHTTP.open "POST",url,false
oXMLHTTP.send
binData=oXMLHTTP.responseText

I am trying to save the stream as a file on the Web server. It isn't
working. I've tried using FS.OpenTextFile, Stream.Write, etc.
Nothing is working.

Anyone have any sample code on how to do this?
Thanks

Apr 2 '07 #1
1 4569

<ee****@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Hi,

A site Im working with has an API that allows one to retrieve files.
The file is a Word doc sent as a byte stream.

url="blah.asp?fileid=777777"
set oXMLHTTP=server.CreateObject("MSXML2.ServerXMLHTTP .4.0")
oXMLHTTP.open "POST",url,false
oXMLHTTP.send
binData=oXMLHTTP.responseText

I am trying to save the stream as a file on the Web server. It isn't
working. I've tried using FS.OpenTextFile, Stream.Write, etc.
Nothing is working.

Anyone have any sample code on how to do this?
Thanks
Dim oWinHTTP
Dim oStream

Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

oWinHTTP.Open "GET", "blah.asp?fileid=777777", False
oWinHTTP.Send

If oWinHTTP.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write oWinHTTP.responseBody
oStream.SaveToFile "c:\temp\blah777777.doc"
oStream.Close
End If

BTW, Are you sure you need a POST ? Your not sending any data in the send
then GET would be more appropriate.

Apr 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Angel Filev | last post: by
1 post views Thread by not_a_commie | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.