You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash
# Directory containing files to upload
DIRECTORY="PATH TO DIRECTORY"
# Query GoFile API to find the best server for upload
SERVER=$(curl -s https://api.gofile.io/servers | jq -r '.data.servers[0].name')
# Replace this with your GoFile account token
ACCOUNT_TOKEN=""
# Extract the folder ID from the provided folder link
FOLDER_ID=""
echo "All files will be uploaded to folder ID: $FOLDER_ID"
echo
# Recursively find and loop through each file in the directory
find "$DIRECTORY" -type f | while read -r FILE; do
echo "Uploading: $FILE"
# Upload the file to the specified GoFile folder
UPLOAD_RESPONSE=$(curl -s -F "file=@$FILE" \
-F "folderId=${FOLDER_ID}" \
-F "token=${ACCOUNT_TOKEN}" \
"https://${SERVER}.gofile.io/uploadFile")
# Extract success status and the download link
SUCCESS=$(echo "$UPLOAD_RESPONSE" | jq -r '.status')
FILE_LINK=$(echo "$UPLOAD_RESPONSE" | jq -r '.data.downloadPage')
# Display upload status
if [[ "$SUCCESS" == "ok" ]]; then
echo "Uploaded: $FILE"
echo "Download link: $FILE_LINK"
else
echo "Failed to upload: $FILE. Response: $UPLOAD_RESPONSE"
fi
echo
done
echo "All files have been uploaded to the folder."
I got to here so far, but it requires you to create a folder to your gofile account first
Any way to modify the script to upload a folder recursively?
The text was updated successfully, but these errors were encountered: