Download a file into array (using std.net.curl.download)

notna notna.remove.this at ist-einmalig.de
Wed Jul 7 10:27:47 UTC 2021


On Monday, 5 July 2021 at 15:08:45 UTC, MoonlightSentinel wrote:
> On Monday, 5 July 2021 at 14:57:20 UTC, BoQsc wrote:
>> Let's say I can't store information into files.
>> Is it possible to download a file into an array.
>
> Yes, use 
> [`get`](https://dlang.org/phobos/std_net_curl.html#.get):
>
> ```d
> import std.net.curl;
>
> void main()
> {
>     char[] content = 
> get("https://gist.githubusercontent.com/deekayen/4148741/raw/98d35708fa344717d8eee15d11987de6c8e26d7d/1-1000.txt");
> }
> ```

On Windows:
```
::> dmd curl_get.d
::> .\curl_get.exe

object.Error@(0): Access Violation
----------------
0x0283CA66
0x0041DE8D
0x004023A2
0x00402308
0x00414D33
0x00414CAD
0x00414B48
0x0040D41F
0x00402363
0x74B96359 in BaseThreadInitThunk
0x773887A4 in RtlGetAppContainerNamedObjectPath
0x77388774 in RtlGetAppContainerNamedObjectPath
```

Nice and helpful Error messages is on the top of our desires 
list, right?


More information about the Digitalmars-d-learn mailing list