Clatter LabsHelp Center

How do I upload a zip with the API?

How-toUpdated
FILE=storefront.zip
SIZE=$(wc -c < $FILE | tr -d ' ')
UP=$(curl -s $CB/v1/buckets/BUCKET_ID/uploads \
  -H "Authorization: Bearer $CLATTER_API_KEY" -H "X-Clatter-Account: $CLATTER_ACCOUNT_ID" \
  -H "Content-Type: application/json" -d "{\"name\": \"$FILE\", \"size\": $SIZE}" | jq -r .id)

split -b 16777216 -d -a 5 $FILE part-
i=0
for p in part-*; do
  curl -s -X PUT $CB/v1/uploads/$UP/chunks/$i \
    -H "Authorization: Bearer $CLATTER_API_KEY" -H "X-Clatter-Account: $CLATTER_ACCOUNT_ID" \
    -H "Content-Type: application/octet-stream" --data-binary @$p > /dev/null
  i=$((i+1))
done

curl -s -X POST $CB/v1/uploads/$UP/complete \
  -H "Authorization: Bearer $CLATTER_API_KEY" -H "X-Clatter-Account: $CLATTER_ACCOUNT_ID"

$CB is https://api.codebuckets.clatterlabs.xyz. The key needs buckets:write. Python and JavaScript versions are in the Quickstart.

Related articles

Still need help?

Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.

Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyz
For deleting your whole account or the data of one service.