Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -Path RestSharp.dll
- $gw2raidar_url = "https://www.gw2raidar.com"
- $last_upload_file = "last_upload_time.json"
- $arcdps_logs = "<PATH TO arcdps.cbtlogs GOES HERE>"
- $username = '<YOUR USERNAME HERE>'
- $password = '<YOUR PASSWORD HERE>'
- # Lookup all files since the last time we uploaded anything
- if (Test-Path $last_upload_file) {
- $last_upload_time = Get-Content -Raw -Path $last_upload_file | ConvertFrom-Json | Select-Object -ExpandProperty "DateTime" | Get-Date
- $files = @(Get-ChildItem -Recurse -File -Include "*.evtc.zip" -Name -LiteralPath $arcdps_logs | Where-Object { $_.LastWriteTime -gt $last_upload_time})
- } else {
- $files = @(Get-ChildItem -Recurse -File -Include "*.evtc.zip" -Name -LiteralPath $arcdps_logs)
- }
- ForEach($f in $files) {
- Write-Output "Uploading ${f}"
- $f = Join-Path $arcdps_logs $f
- try {
- $client = New-Object RestSharp.RestClient($gw2raidar_url)
- $req = New-Object RestSharp.RestRequest("/api/upload.json")
- $req.Method = [RestSharp.Method]::POST
- $req.AddFile("file", $f) | Out-Null
- $req.AddParameter("username", $username) | Out-Null
- $req.AddParameter("password", $password) | Out-Null
- $resp = $client.Execute($req)
- if ($resp.ResponseStatus -ne [RestSharp.ResponseStatus]::Completed) {
- throw "Request was not completed"
- }
- if ($resp.StatusCode -ne "OK") {
- throw "Request failed with status $resp.StatusCode"
- }
- Write-Output $resp.Content
- Write-Output "Upload successful..."
- } catch {
- Write-Output $_.Exception.Message
- Write-Output "Upload failed..."
- Read-Host -Prompt "Press Enter to exit"
- exit
- }
- }
- # Save the current time as
- Get-Date | Select-Object -Property DateTime | ConvertTo-Json | Out-File -Force $last_upload_file
- Read-Host -Prompt "Press Enter to exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement