dx upload

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

You can use the —brief flag with the dx upload command to print only a DNAnexus ID rather than the output shown above. This 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

You can use the wildcard * to upload multiple files.

The following command will upload all of the files inside the /Users/alice/ directory. This directory should contain only files and not sub-directories.

$ 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

NOTE: 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.

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 TAGparameter. 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

Hiding the 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 updated

Copyright 2024 DNAnexus