Created
February 7, 2022 19:40
-
-
Save gmelodie/3027b9297b53ebbe2ffd7f9d703f2d86 to your computer and use it in GitHub Desktop.
Pin directory CID in estuary bug PoC
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
testdir="/tmp/testfs" | |
esturl="http://localhost:3004" | |
# create a collection on estuary first with: curl -X POST http://localhost:3004/collections/create -d '{ "name": "A new collection", "description": "A new collection test" }' -H "Content-Type: application/json" -H "Authorization: Bearer $APIKEY" | |
# then paste the collection's UUID below | |
coluuid="YOUR-COLLECTION-UUID" | |
# make sure it's empty | |
rm -rf $testdir | |
# remake test directory with dummy files | |
mkdir $testdir | |
for i in $(seq 10) | |
do | |
echo "hello $i" > $testdir/file$i.txt | |
done | |
# pin directory to ipfs | |
dircid=$(ipfs add -r $testdir 2>/dev/null | tail -n 1 | cut -d " " -f 2) | |
echo "Added folder to ipfs, CID=$dircid" | |
# add dir's CID to collection | |
# $APIKEY is a variable containing your api key/token for estuary, create it with (on your shell): export APIKEY=your-api-key-here | |
echo "Adding directory $dircid to collection $coluuid" | |
curl -X POST $esturl/content/add-ipfs -d "{ \"collection\": \"$coluuid\", \"collectionPath\": \"/testdir\", \"name\": \"testdir\", \"root\": \"$dircid\" }" -H "Content-Type: application/json" -H "Authorization: Bearer $APIKEY" 2>/dev/null | jq | |
# and get the collections fs contents | |
echo "Here's the listing for collection $coluuid" | |
curl -X GET -H "Authorization: Bearer $APIKEY" "$esturl/collections/fs/list?col=$coluuid&dir=/testdir" 2>/dev/null | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment