Uploading Files Using dx

You can upload files to the DNAnexus platform using the command dx upload. You can also upload data using the DNAnexus Upload Agent, a fast and convenient command-line client. For uploading multiple or large files (>50 MB), we recommend that you use Upload Agent, which allows you to upload up to 1000 files concurrently and resume uploads in case of network interruption.

Uploading Files

Uploading one file

You can use the dx upload command followed by a file path to upload one local file.

$ dx upload /Users/alice/README.txt [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags - Outgoing links - Created Sun Jan 1 12:00:01 2017 Created by alice Last modified Sun Jan 1 12:00:02 2017 archivalState "live" Media type

TIP: You can use the --brief flag with the dx upload command to print only a DNAnexus ID rather than the output shown above. The brief flag is useful if you want to save the file ID of the uploaded file.

$ dx upload /Users/alice/README.txt --brief file-xxxx

If you are trying to upload a file hosted at a publicly accessible URL rather than locally, you can use the URL Fetcher (platform login required to access this link) app.

Uploading multiple files

You can also use the dx upload command followed by multiple file paths to upload multiple local files.

$ dx upload /Users/alice/README.txt /Users/bob/README.txt [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags - Outgoing links - Created Sun Jan 1 09:00:01 2017 Created by alice Last modified Sun Jan 1 09:00:02 2017 archivalState "live" Media type [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/bob/README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags - Outgoing links - Created Sun Jan 1 09:00:03 2017 Created by alice Last modified Sun Jan 1 09:00:04 2017 archivalState "live" Media type
TIP: You can use the wildcard * to upload multiple files. For more information about using wildcards, please see the Path Resolution page.

The following command will upload all of the files inside the /Users/alice/ directory. This directory should contain only files and not sub-directories. For information about uploading sub-directories, please see the Uploading Directories section below.

$ dx upload /Users/alice/* [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/INSTALL.txt ID file-xxxx Class file Project project-xxxx Folder / Name INSTALL.txt State closing Visibility visible Types - Properties - Tags - Outgoing links - Created Sun Jan 1 09:00:01 2017 Created by alice Last modified Sun Jan 1 09:00:02 2017 archivalState "live" Media type [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags - Outgoing links - Created Sun Jan 1 09:00:03 2017 Created by alice Last modified Sun Jan 1 09:00:04 2017 archivalState "live" Media type

Uploading Directories

You can specify the ‑r/‑‑recursive parameter with the dx upload command to recursively upload one or more directories or folders and maintain their respective structures.

$ dx upload -r /Users/alice [===========================================================>] Uploaded 597 of 5977 bytes (100%) /Users/alice/INSTALL.txt [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt
$ dx upload -r /Users/alice /Users/bob [===========================================================>] Uploaded 597 of 5977 bytes (100%) /Users/alice/INSTALL.txt [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/bob/README.txt

You can use the dx ls command to list the uploaded folders and files.

$ dx ls Users/
$ dx ls Users alice/ bob/
$ dx ls Users/alice INSTALL.txt README.txt
TIP: If the local uploaded directory ends with the / character, only the contents of the directory will be uploaded, not the directory itself.

Uploading Files with Metadata

You can specify object metadata using the dx upload command. For more information about metadata, see the Manage Metadata page.

TIP: If multiple files are uploaded, tags and properties are applied to all of the files.

Properties

You can use the --property KEY=VALUE parameter to add metadata to the file being uploaded. The parameter may be repeated as necessary, e.g. --property key1=val1 --property key2=val2, to link multiple metadata fields as key-value pairs.

$ dx upload /Users/alice/README.txt --property name=alice [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties name=alice Tags - Outgoing links - Created Sun Jan 1 09:00:01 2017 Created by alice Last modified Sun Jan 1 09:00:02 2017 archivalState "live" Media type

Tags

You can also add tags to uploaded files with the dx upload command using the --tag TAG parameter. The parameter may be repeated as necessary, e.g. --tag tag1 --tag tag2, to link multiple tags to a file.

$ dx upload /Users/alice/README.txt --tag alice [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags alice Outgoing links - Created Sun Jan 1 09:00:01 2017 Created by alice Last modified Sun Jan 1 09:00:02 2017 archivalState "live" Media type

Advanced Options

Redirecting uploaded files

You can use the --path/‑‑destination parameter to specify the DNAnexus destination path. If the path is not specified, dx upload will default to the current project and folder. You can determine your current project and folder using the command dx pwd.

$ dx upload /Users/alice/README.txt --path /DNAnexus/User/ [===========================================================>] Uploaded 597 of 597 bytes (100%) /Users/alice/README.txt ID file-xxxx Class file Project project-xxxx Folder /DNAnexus/User Name README.txt State closing Visibility visible Types - Properties - Tags alice Outgoing links - Created Sun Jan 1 09:00:01 2017 Created by alice Last modified Sun Jan 1 09:00:02 2017 archivalState "live" Media type

Uploading from stdin

You can upload data directly from standard input. This is very useful when streaming the upload while the file is generated.

$ cat /Users/alice/README.txt | dx upload - --path README.txt ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags alice Outgoing links - Created Sun Jan 1 12:00:01 2017 Created by alice Last modified Sun Jan 1 12:00:02 2017 archivalState "live" Media type

Buffers

You can specify the --buffer-size parameter with the dx upload command to set the write buffer size in bytes. When uploading large files from standard input, you will need to manually set a --buffer-size because the dx command does not know the file size beforehand.

$ cat /Users/alice/big_file.txt --path big_file.txt | dx upload - --buffer-size 1073741824 ID file-xxxx Class file Project project-xxxx Folder / Name big_file.txt State closing Visibility visible Types - Properties - Tags alice Outgoing links - Created Sun Jan 1 12:00:01 2017 Created by alice Last modified Sun Jan 1 12:05:00 2017 archivalState "live" Media type

Hide progress bar

You can specify the --no-progress flag with the dx upload command to hide the progress bar.

$ dx upload /Users/alice/README.txt --no-progress ID file-xxxx Class file Project project-xxxx Folder / Name README.txt State closing Visibility visible Types - Properties - Tags alice Outgoing links - Created Sun Jan 1 12:00:01 2017 Created by alice Last modified Sun Jan 1 12:00:02 2017 archivalState "live" Media type

Last edited by Samantha Zarate, 2017-10-12 07:21:20

 Feedback