soiz1 commited on
Commit
c8abb98
·
verified ·
1 Parent(s): 15b3d8e

Create upload.sh

Browse files
Files changed (1) hide show
  1. upload.sh +32 -0
upload.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Exit on error
4
+ set -e
5
+
6
+ # Check if the token is set
7
+ if [ -z "$sc4sc_token" ]; then
8
+ echo "Error: Environment variable sc4sc_token is not set."
9
+ exit 1
10
+ fi
11
+
12
+ # Define variables
13
+ SPACE_REPO="sc4sc/editor"
14
+ API_URL="https://huggingface.co/api/spaces/$SPACE_REPO"
15
+ TEMP_DIR=$(mktemp -d)
16
+ ZIP_FILE="$TEMP_DIR/upload.zip"
17
+
18
+ # Create zip of all files and folders in current directory
19
+ zip -r "$ZIP_FILE" . -x "*.git*" -x "$ZIP_FILE"
20
+
21
+ # Upload to the space
22
+ echo "Uploading to Hugging Face Space: $SPACE_REPO"
23
+
24
+ curl -X POST "$API_URL/upload" \
25
+ -H "Authorization: Bearer $sc4sc_token" \
26
+ -H "Content-Type: application/zip" \
27
+ --data-binary @"$ZIP_FILE"
28
+
29
+ # Clean up
30
+ rm -rf "$TEMP_DIR"
31
+
32
+ echo "✅ Upload completed successfully."