Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder of Files #6

Open
LanceMagnaye26 opened this issue Jan 8, 2025 · 1 comment
Open

Folder of Files #6

LanceMagnaye26 opened this issue Jan 8, 2025 · 1 comment

Comments

@LanceMagnaye26
Copy link

Any way to modify the script to upload a folder recursively?

@LanceMagnaye26
Copy link
Author

LanceMagnaye26 commented Jan 8, 2025

#!/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant