In this post, I will show you how to quickly upload files to Rackspace Cloud Files using only the Linux CLI (i.e., no SDKs, Rackspace-specific tools, or anything that is not already installed on a standard Linux distro).
This post will assume you already have some basic understanding of how application programming interfaces (APIs) work, you have a Rackspace Cloud account (w/Cloud Files), and understand the basics of the Linux CLI (e.g., you know how to use cURL). See my Rackspace API article on my wiki for more in-depth explanations and examples.
Note: The following commands use Python. It should work with any version of Python, however, it was tested with Python 2.7.4.
First get your 24-hour-valid token:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then, use a for-loop to upload your files (e.g., all of the PNG files in you present working direcory) to a given container (e.g., “sandbox”):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ REGION=dfw; CONTAINER_NAME=sandbox; for i in *.png; do curl -XPUT -T $i -v -H "X-Auth-Token:$MYRAXTOKEN" -H"Content-Type: text/plain" "https://storage101.${REGION}1.clouddrive.com/v1/MossoCloudFS_ffff-ffff-ffff-ffff-ffff/${CONTAINER_NAME}/$i"; done