![]() |
OpenMS
|
Convenience wrapper around NetworkGetRequest for one-shot HTTP/HTTPS downloads.
More...
#include <OpenMS/SYSTEM/Network.h>
Static Public Member Functions | |
| static void | downloadFile (const std::string &url, const std::string &download_folder) |
Download url to download_folder and return when the file is fully written. | |
Convenience wrapper around NetworkGetRequest for one-shot HTTP/HTTPS downloads.
Single-method utility used by tooling that needs to fetch a remote URL to disk without composing a NetworkGetRequest pipeline by hand. Synchronous (the call blocks until the transfer finishes or fails).
|
static |
Download url to download_folder and return when the file is fully written.
Internally creates a NetworkGetRequest with a 10-minute (600 second) timeout and runs it synchronously. The destination filename is derived from the URL:
"?query" and "#fragment" suffixes are stripped first;"https://host/a/b/c.tsv" → "c.tsv");"download" is used as a fallback. If a file with the same name already exists in download_folder, the suffixes ".0", ".1", ".2", ... are tried in order until an unused name is found — existing files are never overwritten.An empty download_folder is treated as "./" (the current working directory). No trailing-slash normalisation is performed on the directory string.
Success path: writes the response bytes to the destination in binary mode and emits two OPENMS_LOG_INFO lines (download successful + final on-disk path). Failure paths throw:
NetworkGetRequest),| [in] | url | Source URL. |
| [in] | download_folder | Destination directory; "" is treated as "./". |
| OpenMS::Exception::IOException | on any of the failure paths described above. |