dx download
Learn how to use the dx download command to download data and share files among collaborators.
Downloading a Single File
The dx download
command can download a file using either its file ID or its name. Files will be downloaded into the current local directory and will inherit their names from the platform unless specified otherwise.
Downloading Using a File ID
Using dx download
to download a file using its ID is particularly useful in situations where there may be different files with the same name in the same folder. To get a file's ID via the web UI, select the file and click "Info". There will be a field labeled "ID" with a corresponding file ID of the format file-xxxx.
INFO: You can remove the progress bar using the flag
--no-progress
. There will be no feedback after executing the commanddx download
. This is useful for scripting.
Downloading Using a Filename
Using dx download
to download a file using its name differs slightly based on whether or not the filename is unique within its folder. To find your current working directory within DNAnexus, use the command dx pwd
to list the files in a directory, use the command dx ls
.
Unique Filename
If the filename is unique within its folder, downloading a file using its name will look very similar to downloading a file using its ID.
Non-Unique Filename
If a filename is not unique within its folder, upon executing dx download
you will be prompted to select which file you intend on downloading.
If you use the -a/--all
flag, all files will be downloaded. However, your local operating system may not allow multiple files of the same name to be in the same folder.
Downloading Using a File Path
If the file is contained within a folder, dx download
can also use file paths as input. For example, if file file_name is contained within the folder my_folder/
in the project project-xxxx, the command changes accordingly. Projects can be identified by either their name or ID; if multiple projects are named identically, you will be prompted to select one.
Downloading Multiple Files
If you only want to download a few files at once, you can use multiple filenames or file IDs as inputs to dx download
.
Downloading a Folder
If you want to download multiple files at once using dx download
, moving desired files to a single folder can be the simplest solution. The -r/--recursive
flag is required to download folders.
INFO: By default, if multiple files of the same name exist in a folder, only one of the files will be downloaded. Add the
-a/--all
flag to download all files, even if their names match. Please note that your local operating system may not allow multiple files of the same name to be in the same folder.
Generating Download URLs
Download URLs are useful for sharing files with collaborators who may or may not have accounts on DNAnexus. URLs may be pasted directly into a browser window for automatic download or used as input for the bash command wget
.
Generating a Single URL
The dx make_download_url
command is used to generate download URLs.
The command can be used on both file names and file IDs. The path to the file should include the project context, such as project-xxxx:file-yyyy
, or project-xxxx:/path/to/file.txt
.
As shown above, if the file name used as input is not unique within its folder, you will be prompted to select a file.
Generating Multiple URLs
You must write a script in order to generate download URLs for multiple files.
URL Expiration Dates
By default, URLs expire after one day. However, you can change the duration so that the URL lasts for a longer or shorter period of time.
After the specified duration of time, downloading the file using the URL will no longer work. This is useful for restricting access to files.
Advanced Options
Resuming Downloads
If a file has only been partially downloaded, the -f/--overwrite
flag will resume the download. However, if a file has been completely downloaded, the -f/--overwrite
flag will overwrite the downloaded file.
Redirecting Downloaded Files
By default, files will assume the same name they had on the platform when downloaded. However, you can override this with the -o/--output
flag. This is useful if your script assumes a specific file name.
Redirecting to a Different Folder
You may also redirect the outputs to a different folder using the -o/--output
flag. Please note that if you are redirecting the outputs to a different folder, dx download
will not create the folders; they must already exist before downloading the files.
Printing to stdout
The command dx download file-xxxx -o -
will redirect the contents of the file file-xxxx
to stdout. This has the same functionality as the command dx cat file-xxxx
.
Additional information
Executing the dx download --help
command will show all of the flags available to use in conjunction with dx download
. The message printed by this command is identical to the one displayed in the brief description of dx download
. More information about dx make_download_url
can be found on the same page and by running the command dx make_download_url --help
.
Last updated