BASH Script to Upload Directory to a Cloud Files Container automatically

Hi guys. So I was working with cloud files API and I thought I would put together a piece of code that allows uploads of an entire file structure to a cloud files container. It won’t work with sub directories yet, but it’s simple enough to give anyone a better understanding of how this works. Please note the token I am using is not a real genuine token.

!/bin/sh

# This Scripts Uploads an entire file structure to a cloud files container

# CLOUD FILES TOKEN
TOKEN='AAAjsa_x-Pe2YuyHVM7kuS-A67LcZNx4-MOCKTOKENjZ1GoLTwVKcQhyE9t-gZIIBMknJBEtD2JbJbWS4W1Pd7wJqXfxgN2ykVSfhcga1ch-vwBFAvlsjMj-ew6eMSG-TyEG7Q_ABC231'



# Folder to Upload FROM
FILES=/root/cloud-files/files/*

# Container to Upload to
CONTAINER=meh2


for f in $FILES
do

echo "Upload start $f ..."
FILENAME=`basename $f`
# take action on each file

curl -i -X PUT https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_10045567/meh2/$FILENAME -T /root/cloud-files/files/$FILENAME -H "X-Auth-Token: $TOKEN"

done

Leave a Reply

Your email address will not be published. Required fields are marked *