Merge pull request #201 from PetriAsi/feature/support-images

Add _method and use always post with multipart/form-data
This commit is contained in:
Petri Asikainen 2021-07-14 13:02:51 +03:00 committed by GitHub
commit fab7a71abf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,11 +61,15 @@
ErrorAction = 'SilentlyContinue' ErrorAction = 'SilentlyContinue'
} }
#Place holder for intended image manipulation # Place holder for intended image manipulation
# if and when snipe it API gets support for images # if and when snipe it API gets support for images
if($null -ne $body -and $Body.Keys -contains 'image' ){ if($null -ne $body -and $Body.Keys -contains 'image' ){
if($PSVersionTable.PSVersion -ge '7.0'){ if($PSVersionTable.PSVersion -ge '7.0'){
$Body['image'] = get-item $body['image'] $Body['image'] = get-item $body['image']
# As multipart/form-data is always POST we need add
# requested method for laravel named as '_method'
$Body['_method'] = $Method
$splatParameters["Method"] = 'POST'
$splatParameters["Form"] = $Body $splatParameters["Form"] = $Body
} else { } else {
# use base64 encoded images for powershell version < 7 # use base64 encoded images for powershell version < 7