s4s-editor / upload.sh
soiz1's picture
Create upload.sh
c8abb98 verified
raw
history blame
728 Bytes
#!/bin/bash
# Exit on error
set -e
# Check if the token is set
if [ -z "$sc4sc_token" ]; then
echo "Error: Environment variable sc4sc_token is not set."
exit 1
fi
# Define variables
SPACE_REPO="sc4sc/editor"
API_URL="https://huggingface.co/api/spaces/$SPACE_REPO"
TEMP_DIR=$(mktemp -d)
ZIP_FILE="$TEMP_DIR/upload.zip"
# Create zip of all files and folders in current directory
zip -r "$ZIP_FILE" . -x "*.git*" -x "$ZIP_FILE"
# Upload to the space
echo "Uploading to Hugging Face Space: $SPACE_REPO"
curl -X POST "$API_URL/upload" \
-H "Authorization: Bearer $sc4sc_token" \
-H "Content-Type: application/zip" \
--data-binary @"$ZIP_FILE"
# Clean up
rm -rf "$TEMP_DIR"
echo "✅ Upload completed successfully."