Skip to content

Instantly share code, notes, and snippets.

@toshinarin
Last active August 29, 2015 14:14
Show Gist options
  • Save toshinarin/c1ff5696b88471a19436 to your computer and use it in GitHub Desktop.
Save toshinarin/c1ff5696b88471a19436 to your computer and use it in GitHub Desktop.
downloader for attachments of an asana task
#!/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