Last active
August 29, 2015 14:14
-
-
Save toshinarin/c1ff5696b88471a19436 to your computer and use it in GitHub Desktop.
downloader for attachments of an asana task
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
#!/bin/bash | |
if [ $# -ne 3 ]; then | |
echo "Please specify asana API key, dest dir, task id." 1>&2 | |
exit 1 | |
fi | |
API_KEY=$1 | |
TASK_ID=$3 | |
SAVE_DIR="${2}/task_${TASK_ID}" | |
mkdir -p ${SAVE_DIR} | |
attachments=`curl -u ${API_KEY}: https://app.asana.com/api/1.0/tasks/${TASK_ID}/attachments | /usr/local/bin/jq '.data[].id'` | |
echo $attachments | |
for a in $attachments; do | |
attachment=`curl -u ${API_KEY}: https://app.asana.com/api/1.0/attachments/${a}` | |
name=`echo "${attachment}" | /usr/local/bin/jq -r '.data.name'` | |
url=`echo "${attachment}" | /usr/local/bin/jq -r '.data.download_url'` | |
/usr/local/bin/wget -O "${SAVE_DIR}/$name" "$url" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment