AWS Tools for PowerShell 第 5 版 (V5) 正在預覽。若要查看可能變更的 V5 內容,並試用新版本,請參閱版本 5 (預覽) 使用者指南。如需有關中斷變更和遷移至 V5 的特定資訊,請參閱該指南中的遷移主題。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
將內嵌文字內容上傳到 Amazon S3
Write-S3Object
cmdlet 支援將內嵌文字內容上傳至 Amazon S3 的能力。使用 -Content
參數 (別名 -Text
),您可以指定應上傳到 Amazon S3 的文字型內容,而不需先將它轉換為檔案。參數接受簡單的一行字串,以及包含多行的 here 字串。
PS >
# Specifying content in-line, single line text:
PS >
write-s3object
amzn-s3-demo-bucket
-key myobject.txt -content "file content"PS >
# Specifying content in-line, multi-line text: (note final newline needed to end in-line here-string)
PS >
write-s3object
amzn-s3-demo-bucket
-key myobject.txt -content @">>
line 1
>>
line 2
>>
line 3
>>
"@
>>
PS >
# Specifying content from a variable: (note final newline needed to end in-line here-string)
PS >
$x = @"
>>
line 1
>>
line 2
>>
line 3
>>
"@
>>
PS >
write-s3object
amzn-s3-demo-bucket
-key myobject.txt -content $x