Last active
June 28, 2016 08:03
-
-
Save clochix/29a5f4f565e9c9f1b878196d07117a53 to your computer and use it in GitHub Desktop.
Bash functions for dealing with files on CozyCloud
This file contains 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
function cf { | |
case "$1" in | |
list) | |
cozy-monitor curlcouch --pretty _design/file/_view/byfullpath | jq -r '.rows[].value | .path+"/"+.name+" "+._id' | sort | |
;; | |
get) | |
name=$(cozy-monitor curlcouch $2 | jq -r '.name') | |
curl -s -o $name $(sed -n '1,1p' /etc/cozy/couchdb.login):$(sed -n '2,1p' /etc/cozy/couchdb.login)@127.0.0.1:5984/cozy/$(cozy-monitor curlcouch $2 | jq '.binary.file.id')/file | |
echo $name | |
;; | |
post) | |
curl -X POST -F name=$2 -F overwrite=true -F path= -F "file=@$2" 'localhost:9121/files' | |
;; | |
postall) | |
for i in $( ls ); do | |
curl -X POST -F name=$i -F overwrite=true -F path= -F "file=@$i" 'localhost:9121/files' | |
done | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function requires
jq
, a JSON command-line processor.apt-get install jq
is your friend ;-)