मैं एडब्ल्यूएस में मौजूदा लैम्ब्डा फ़ंक्शन में अपनी फ़ाइल को तैनात करने के लिए AWS अद्यतन-LMFunctionCode का उपयोग करने का प्रयास कर रहा हूं।पावरहेल में, मैं स्थानीय ज़िप फ़ाइल का बेस 64 एन्कोडेड मेमोरीस्ट्रीम कैसे प्राप्त कर सकता हूं?
प्रकाशन-एलएमफ़ंक्शन से अलग हो जहां मैं ज़िपफाइल (-फंक्शनक्शन) के लिए केवल एक रास्ता प्रदान कर सकता हूं, अद्यतन-एलएमफ़ंक्शन अपने -Zipfile तर्क के लिए मेमोरीस्ट्रीम चाहता है।
क्या डिस्क से स्थानीय ज़िपफाइल को स्मृति स्ट्रीम में लोड करने का एक उदाहरण है जो काम करता है? मेरे प्रारंभिक कॉल त्रुटियों कि फ़ाइल अनज़िप नहीं किया जा सकता ... Powershell समारोह के लिए
$deployedFn = Get-LMFunction -FunctionName $functionname
"Function Exists - trying to update"
try{
[system.io.stream]$zipStream = [system.io.File]::OpenRead($zipFile)
[byte[]]$filebytes = New-Object byte[] $zipStream.length
[void] $zipStream.Read($filebytes, 0, $zipStream.Length)
$zipStream.Close()
"$($filebytes.length)"
$zipString = [System.Convert]::ToBase64String($filebytes)
$ms = new-Object IO.MemoryStream
$sw = new-Object IO.StreamWriter $ms
$sw.Write($zipString)
Update-LMFunctionCode -FunctionName $functionname -ZipFile $ms
}
catch{
$ErrorMessage = $_.Exception.Message
Write-Host $ErrorMessage
break
}
डॉक्स यहाँ हो रहे हैं: http://docs.aws.amazon.com/powershell/latest/reference/items/Update-LMFunctionCode.html हालांकि यह एक फ्रेम में रहने के लिए चाहता है ...
(। FYI करें, कि ब्लॉक एक बड़ा ट्राई/कैच कि पकड़ता जब Get-LMFunction functionName खोजने में विफल रहा है) –