-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathupload.cmd
More file actions
93 lines (78 loc) · 1.93 KB
/
Copy pathupload.cmd
File metadata and controls
93 lines (78 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@echo off
setlocal enabledelayedexpansion
:: Debug Mode (set to 1 to enable)
set "DEBUG=0"
:: Check if curl is installed
where curl >nul 2>&1
if errorlevel 1 (
echo ERROR: curl is not installed or not in PATH.
pause
exit /b 1
)
:: Check if jq is installed
where jq >nul 2>&1
if errorlevel 1 (
echo ERROR: jq is not installed or not in PATH.
pause
exit /b 1
)
:: Check if a file argument is provided
if "%~1"=="" (
echo ERROR: No file specified!
echo Usage: %~nx0 file_to_upload
pause
exit /b 1
)
:: Check if the file exists
set "FILE=%~1"
if not exist "%FILE%" (
echo ERROR: File "%FILE%" not found!
pause
exit /b 1
)
:: Query GoFile API for the best server
for /f "delims=" %%i in ('curl -s https://api.gofile.io/servers') do (
set "SERVER_RESPONSE=%%i"
)
:: Debug: Show API response
if "%DEBUG%"=="1" (
echo Server Response: !SERVER_RESPONSE!
)
:: Extract the correct server name
for /f "delims=" %%i in ('echo !SERVER_RESPONSE! ^| jq -r ".data.servers[0].name"') do (
set "SERVER=%%i"
)
:: Debug: Show selected server
if "%DEBUG%"=="1" (
echo Selected Server: !SERVER!
)
:: Check if server was retrieved
if "!SERVER!"=="" (
echo ERROR: Failed to retrieve a server from GoFile API.
pause
exit /b 1
)
:: Upload the file with a progress bar
echo Uploading file, please wait...
for /f "delims=" %%i in ('curl --progress-bar -F "file=@%FILE%" https://!SERVER!.gofile.io/uploadFile') do (
set "UPLOAD_RESPONSE=%%i"
)
:: Debug: Show upload response
if "%DEBUG%"=="1" (
echo Upload Response: !UPLOAD_RESPONSE!
)
:: Extract the download link
for /f "delims=" %%i in ('echo !UPLOAD_RESPONSE! ^| jq -r ".data.downloadPage"') do (
set "LINK=%%i"
)
:: Check if upload was successful
if "!LINK!"=="" (
echo ERROR: Upload failed or download link not retrieved.
pause
exit /b 1
)
:: Show the download link
echo.
echo Upload successful! Download link:
echo !LINK!
pause