File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed
Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,41 @@ if ($env:WEBHOOK_URL) {
1717}
1818
1919if ($env: DISCORD_FILE_WEBHOOK ) {
20- Invoke-RestMethod - Uri $env: DISCORD_FILE_WEBHOOK - Method Post - InFile " ..\vMenu-$env: VERSION_NAME .zip" - ContentType " multipart/form-data"
20+ # filepath to file to upload
21+ $filePath = " vMenu-$env: VERSION_NAME .zip"
22+
23+ # Check if file exists
24+ if (-Not (Test-Path $filePath )) {
25+ Write-Host " File not found: $filePath "
26+ exit 1
27+ }
28+
29+ # make a multipart-formdata request
30+ $boundary = [System.Guid ]::NewGuid().ToString()
31+ $LF = " `r`n "
32+
33+ # Headers
34+ $headers = @ {
35+ " Content-Type" = " multipart/form-data; boundary=$boundary "
36+ }
37+
38+ # multipart body
39+ $body = (
40+ " --$boundary " ,
41+ " Content-Disposition: form-data; name=`" file`" ; filename=`" $ ( [System.IO.Path ]::GetFileName($filePath )) `" " ,
42+ " Content-Type: application/octet-stream" ,
43+ " " ,
44+ [System.IO.File ]::ReadAllText($filePath ),
45+ " --$boundary --" ,
46+ " "
47+ ) -join $LF
48+
49+ # Send HTTP POST-request
50+ $response = Invoke-WebRequest - Uri $env: DISCORD_FILE_WEBHOOK - Method Post - Headers $headers - Body $body
51+
52+ # Show response
53+ Write-Host " Response: $ ( $response.StatusCode ) - $ ( $response.StatusDescription ) "
54+
2155 Write-Output " File webhook sent."
2256} else {
2357 Write-Output " No file webhook URL defined, skipping file webhook."
You can’t perform that action at this time.
0 commit comments