2014-06-17 20:15:18 +00:00
|
|
|
#!powershell
|
|
|
|
# WANT_JSON
|
|
|
|
|
2014-06-17 20:44:06 +00:00
|
|
|
$params = New-Object psobject;
|
2014-06-17 20:15:18 +00:00
|
|
|
If ($args.Length -gt 0)
|
|
|
|
{
|
|
|
|
$params = Get-Content $args[0] | ConvertFrom-Json;
|
|
|
|
}
|
|
|
|
|
|
|
|
$src = '';
|
|
|
|
If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'src')
|
|
|
|
{
|
|
|
|
$src = $params.src;
|
|
|
|
}
|
|
|
|
Else
|
|
|
|
{
|
|
|
|
If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'path')
|
|
|
|
{
|
|
|
|
$src = $params.path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
If (-not $src)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$bytes = [System.IO.File]::ReadAllBytes($src);
|
|
|
|
$content = [System.Convert]::ToBase64String($bytes);
|
|
|
|
|
2014-06-17 20:44:06 +00:00
|
|
|
$result = New-Object psobject;
|
2014-06-17 20:15:18 +00:00
|
|
|
$result | Add-Member -MemberType NoteProperty -Name content -Value $content;
|
|
|
|
$result | Add-Member -MemberType NoteProperty -Name encoding -Value 'base64';
|
|
|
|
echo $result | ConvertTo-Json;
|