I am trying to get an image (or any binary data) downloaded from a website and into a jpg file. I expect I will need to use the Byte[] datatype, but I absolutely can NOT use Callbacks when the data comes in this time.
Here is my example: DIM RequestString as string DIM sTotal as string DIM sBuf as string Sock.Connect("host",80) RequestString = MakeGetRequest("/imagesurl.jpg") 'returns a string like HTTP/1.1 GET /page... \r\n its all correct WRITE #Sock, RequestString, Len(RequestString) 'Code to wait for connection, etc is removed for brevity DO UNTIL(EOF(#Sock)) READ #Sock, sBuf, Lof(Sock) sTotal &= sBuf LOOP CLOSE #Sock And after I separate the Content of the reply and dump it to a file, its not readable, I presume this is because I am trying to write binary data as a string p1 = InStr(sTotal, "\r\n\r\n") ImgData = Mid(sTotal, p1) OPEN "localimg.jpg" FOR OUTPUT CREATE AS #myFile WRITE #myFile, ImgData, Len(ImgData) CLOSE #myFile Keep in mind, the http request looks something like HTTP/1.0 200 OK Header-X: Value1 Content-Type: image/jpeg AFdka;h3ijaf #RVA 'Image Data So I need a way to correctly write the binary data to a file without also including the content headers Thank you ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user