Created
September 12, 2019 12:05
Revisions
-
SingingBush created this gist
Sep 12, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ $baseUrl = 'http://api.domain.com/some-service/' Get-ChildItem -Path ".\*.jpg" | Sort-Object Name | % { $response = try { Invoke-RestMethod -uri "$baseUrl/image" -Method Post -Infile $_.Name -ContentType 'image/jpeg' -ErrorAction Stop } catch [System.Net.WebException] { Write-Error "Media Service returned $($_.Exception.Response.StatusCode.Value__) : $($_.Exception.Message)" Exit 1; } write-host "Postimg image for " -nonewline; write-host $_.BaseName -nonewline -foregroundcolor cyan; write-host " {0}" -f $response.id; New-Object PSObject -Property @{ filename = $_.Name; id = $response.id; } } | Export-Csv 'image-upload-result.csv' -Encoding UTF8 -Delimiter "," -Force -NoTypeInformation