Skip to content

Commit

Permalink
add list container/objects, delete operations
Browse files Browse the repository at this point in the history
  • Loading branch information
cail committed Feb 14, 2012
1 parent 9a86339 commit 9b463f3
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions upcs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ Use curl on the backup to upload files to rackspace Cloud Files.
Options are : Options are :
-l list containers/container content
-f format for listing: json/xml
-r Object - Removes object from container
-s - Use Servicenet to upload. -s - Use Servicenet to upload.
-q - Be quiet when uploading. -q - Be quiet when uploading.
-u Username - specify an alternate username than the one stored in config -u Username - specify an alternate username than the one stored in config
Expand Down Expand Up @@ -327,7 +331,7 @@ choose_default=
content_type= content_type=
create_container= create_container=


while getopts ":c:dxsu:k:a:C:qm:" opt; do while getopts ":c:f:dxsu:k:a:C:qm:lr:" opt; do
case $opt in case $opt in
q) q)
QUIET=true QUIET=true
Expand Down Expand Up @@ -356,6 +360,15 @@ while getopts ":c:dxsu:k:a:C:qm:" opt; do
m) m)
create_container=$OPTARG create_container=$OPTARG
;; ;;
l)
list_container=True
;;
r)
delete_object=$OPTARG
;;
f)
format=$OPTARG
;;
x) x)
set -x set -x
;; ;;
Expand All @@ -375,6 +388,26 @@ shift $((OPTIND-1))


[[ -n ${RCLOUD_API_KEY} && -n ${RCLOUD_API_USER} ]] && check_api_key || get_api_key [[ -n ${RCLOUD_API_KEY} && -n ${RCLOUD_API_USER} ]] && check_api_key || get_api_key


formatarg=""
if [[ -n format ]];then
formatarg=?format=${format}
fi

if [[ -n delete_object && -n container ]];then
curl ${options} -k -X DELETE -H "ETag: ${etag}" -H "Content-type: ${ctype}" -H "X-Auth-Token: ${StorageToken}" ${StorageUrl}/${container}/${delete_object}
exit $?
fi

if [[ -n list_container && -n container ]];then
curl ${options} -k -X GET -H "ETag: ${etag}" -H "Content-type: ${ctype}" -H "X-Auth-Token: ${StorageToken}" ${StorageUrl}/${container}${formatarg}
exit $?
fi

if [[ -n list_container ]];then
curl ${options} -k -f -X GET -H "ETag: ${etag}" -H "Content-type: ${ctype}" -H "X-Auth-Token: ${StorageToken}" ${StorageUrl}
exit $?
fi

if [[ -n ${create_container} ]];then if [[ -n ${create_container} ]];then
create_container ${create_container} create_container ${create_container}
exit $? exit $?
Expand Down Expand Up @@ -426,5 +459,4 @@ for arg in $ARGS;do


put_object ${container} ${file} ${dest_name} put_object ${container} ${file} ${dest_name}
[[ -n ${tarname} ]] && rm -f ${tarname} [[ -n ${tarname} ]] && rm -f ${tarname}
done done

0 comments on commit 9b463f3

Please sign in to comment.