SOLVED How to download a file in R20+

Hi,

How would I go about downloading a (text) file from a webserver? Ideally, this should be done in a separate thread, so the GUI isn’t blocked while waiting for the server response?

I just want to read what’s in the file, it doesn’t need to be stored locally.

I know, using a separate Python plugin it is very easy, but I’d prefer doing it in C++. If it's possible in R20 - R23, even better.

Thanks in advance & greetings,
Frank

hi,

you should have a look at this thread from which, we've updated the documentation.

Using the function ReadFileToMemory you can read the stream to an array and you can use ConvertTextToLines. to have a per-line result

ReadFileToMemory is present since R20 but i didn't tried there.

Let me know if it's working, otherwise I will have a look if i find something better.

Cheers,
Manuel

Hi Manuel,

thanks, that looks exactly like the thing I need!
Was only looking into NetworkHttpHandlerInterface the whole time...

I'll try this out soon and then report back.
Will set this thread to solved, as my question was answered 🙂

Thanks & greetings,
Frank

It's working perfectly, thanks again!
So much easier than I thought 🙂

Cheers,
Frank

hi,

by the way, i forgot to talk about the thread thing.

This thread might help
And of course our manuals about threading

Cheers
Manuel