|
|
|
@ -33,15 +33,32 @@ Else
|
|
|
|
|
}
|
|
|
|
|
If (-not $src)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$result = New-Object psobject @{};
|
|
|
|
|
Fail-Json $result "missing required argument: src";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$bytes = [System.IO.File]::ReadAllBytes($src);
|
|
|
|
|
$content = [System.Convert]::ToBase64String($bytes);
|
|
|
|
|
If (Test-Path $src)
|
|
|
|
|
{
|
|
|
|
|
If ((Get-Item $src).Directory) # Only files have the .Directory attribute.
|
|
|
|
|
{
|
|
|
|
|
$bytes = [System.IO.File]::ReadAllBytes($src);
|
|
|
|
|
$content = [System.Convert]::ToBase64String($bytes);
|
|
|
|
|
|
|
|
|
|
$result = New-Object psobject @{
|
|
|
|
|
$result = New-Object psobject @{
|
|
|
|
|
changed = $false
|
|
|
|
|
encoding = "base64"
|
|
|
|
|
};
|
|
|
|
|
Set-Attr $result "content" $content;
|
|
|
|
|
Exit-Json $result;
|
|
|
|
|
};
|
|
|
|
|
Set-Attr $result "content" $content;
|
|
|
|
|
Exit-Json $result;
|
|
|
|
|
}
|
|
|
|
|
Else
|
|
|
|
|
{
|
|
|
|
|
$result = New-Object psobject @{};
|
|
|
|
|
Fail-Json $result ("is a directory: " + $src);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Else
|
|
|
|
|
{
|
|
|
|
|
$result = New-Object psobject @{};
|
|
|
|
|
Fail-Json $result ("file not found: " + $src);
|
|
|
|
|
}
|
|
|
|
|