Last active
February 15, 2023 18:30
-
-
Save Katzenwerfer/1b980feb21ef76a8c11be4717654375f to your computer and use it in GitHub Desktop.
Send a request to Catbox's API using curl.exe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Catbox-Request { | |
param ( | |
[Parameter( | |
Mandatory, | |
Position = 0, | |
ValueFromPipeline = $true, | |
HelpMessage = "Path to a file or a media URL." | |
)] | |
[ValidateNotNullOrEmpty()] | |
[string] | |
[System.IO.FileInfo]$InputFile, | |
[parameter( | |
Mandatory, | |
Position = 1, | |
HelpMessage = "Type of request to be sent towards the API." | |
)] | |
[ValidateSet( | |
"fileupload", | |
"urlupload", | |
"deletefiles" | |
)] | |
[string] | |
$RequestType, | |
[parameter( | |
Position = 2, | |
HelpMessage = "To get your user hash go to: https://catbox.moe/user/manage.php.`nIf no hash is provided the request will be made anonymously and accountless." | |
)] | |
[string] | |
$UserHash | |
) | |
if ($RequestType -eq "fileupload") { | |
curl.exe -F "reqtype=$RequestType" -F "userhash=$UserHash" -F "fileToUpload=@$InputFile" https://catbox.moe/user/api.php | |
} | |
elseif ($RequestType -eq "urlupload") { | |
curl.exe -F "reqtype=$RequestType" -F "userhash=$UserHash" -F "url=$InputFile" https://catbox.moe/user/api.php | |
} | |
elseif ($RequestType -eq "deletefiles") { | |
curl.exe -F "reqtype=$RequestType" -F "userhash=$UserHash" -F "files=$InputFile" https://catbox.moe/user/api.php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment