Skip to content

Instantly share code, notes, and snippets.

@clochix
Last active June 28, 2016 08:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clochix/29a5f4f565e9c9f1b878196d07117a53 to your computer and use it in GitHub Desktop.
Save clochix/29a5f4f565e9c9f1b878196d07117a53 to your computer and use it in GitHub Desktop.
Bash functions for dealing with files on CozyCloud
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
}
@clochix
Copy link
Author

clochix commented Jun 28, 2016

This function requires jq, a JSON command-line processor. apt-get install jq is your friend ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment