DownloadFile v1

../_images/DownloadFile-v1_dlg.png

DownloadFile dialog.

Summary

Downloads a file from a url to the file system

Properties

Name Direction Type Default Description
Address InOut string Mandatory The address of the network resource to download.
Filename Input string Mandatory The filename to save the download to.

Description

This is a simple algorithm that will download the contents of a url address to a file. It can support http:// and https:// based urls, and if the method is not supplied then http:// will be assumed. For example: If the address is www.mantidproject.org, then this will be adjusted to http://www.mantidproject.org.

Usage

Example - http

#import the os path libraries for directory functions
import os

#Create an absolute path by joining the proposed filename to a directory
#os.path.expanduser("~") used in this case returns the home directory of the current user
savefile = os.path.join(os.path.expanduser("~"), "DownloadedFile.txt")

DownloadFile("http://www.mantidproject.org", savefile)

print("File Exists: {}".format(os.path.exists(savefile)))

Output:

File Exists: True

Example - https

#import the os path libraries for directory functions
import os

#Create an absolute path by joining the proposed filename to a directory
#os.path.expanduser("~") used in this case returns the home directory of the current user
savefile = os.path.join(os.path.expanduser("~"), "DownloadedFile.txt")

DownloadFile("https://raw.githubusercontent.com/mantidproject/mantid/master/README.md", savefile)

print("File Exists:".format(os.path.exists(savefile)))

Output:

File Exists: True

Categories: Algorithm Index | DataHandling

Source

C++ source: DownloadFile.cpp (last modified: 2018-10-05)

C++ header: DownloadFile.h (last modified: 2018-10-05)