Page 1 of 1

Download from Internet to Memory

Posted: Sat Aug 15, 2015 10:09 pm
by KatSeiko
The features of .NET allow you to load any file through HTTP (Stream) as if it is on your local drive. With PureBasic, I have to either download the file to disc and then check if the download was successful, then load the file and delete that temporary file - or I have to program something using direct network controls to receive the file content in small blocks and load everything into memory.

I would love to be able to shortcut this whole nightmare in the future, allowing for maybe this code:

Code: Select all

$URL = "http://www.example.org/example.xml"
*buffer = AllocateMemory(5000)
If Length.i = ReceiveHTTPStream($URL, *buffer) // 0 means "Could not download", anything else is the length of the file received..
  If XML = CatchXML(#PB_Any, *buffer, Length)
    Messagerequester("Success", "Loaded XML File from Internet")
  EndIf
EndIf
What do you think?