Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash Script to Download Files from GridFS
#!/bin/bash
while read -r line; do
file=$(echo "$line" | awk -F'\t' '{ print $1 }')
[[ $file == 'connecting to'* ]] && continue
file_id="$(cut -d'|' -f1 <<<"$file")"
file_key="$(cut -d'|' -f2 <<<"$file")"
mkdir $file_id && cd "$_"
mongofiles -d meteor --prefix="cfs_gridfs.filesStore" get_id 'ObjectId("'$file_key'")'
cd ../
done < <(mongo meteor --eval 'db.cfs.files.filerecord.find().forEach(function(o) {if (o.copies) {print(o._id + "|" + o.copies.filesStore.key);}})')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.