File Upload and Download

The Materials Commons API supports uploading files. If you have a large number of files, or individual files that are bigger than 250MB it is recommended that you use Globus to perform your uploads and downloads. Showing how to use the Globus API is outside the scope of this documentation.

# Create directory off of project root directory
dir = c.create_directory(, "d1",

# Upload file in /tmp to newly created directory
file = c.upload_file(,, "/tmp/file-to-upload.txt")

# Download newly uploaded file and write it to a different name in /tmp
c.download_file(,, "/tmp/newly-downloaded-file.txt")

# Download file by path on server. Project file paths start with / as their root, so
# to download the file we uploaded into d1 named file-to-upload.txt it will be located
# on the server at /d1/file-to-upload.txt.
c.download_file_by_path(, "/d1/file-to-upload.txt", "/tmp/download-again.txt")

# Rename the file we previously uploaded from file-to-upload.txt to file.txt
file = c.rename_file(,, "file.txt")

# Move the file from the d1 directory to the root directory
file = c.move_file(,,

# Delete the uploaded file