![](/img/trans.png)
[英]How to check if local file is same as S3 object without downloading it with boto3?
[英]Decrypt an object in AWS S3 without downloading it to local system
我在s3存儲桶中有一個加密文件。 我想以編程方式對其進行解密,而無需將其下載到本地計算機上。 是否可以解密加密的文件而無需將其下載到本地計算機上?
我用來加密文件的內容:boto3庫,用於加密aws sdk的KMS密鑰,python腳本
我絕對可以下載此文件,然后在本地計算機中將其解密,如下所示:
with aws_encryption_sdk.stream(
mode='d',
source=src_file,
key_provider=kms_key
) as decryptor:
for block in decryptor:
tgt_file.write(block)
但是,如果我將文件下載到本地系統,則可以這樣做。 我不想下載文件。 我想在s3存儲桶中對其解密,並使下一個進程能夠對該解密文件進行處理。
任何指針將不勝感激!
不,這不可能直接實現。 但是,您可以創建一個AWS Lambda,以便在文件上傳時可以運行Lambda進行解密。 有關更多詳細信息,請參閱將AWS Lambda與Amazon S3一起使用 。
在偽代碼中,您將執行以下操作:
def lambda_handler(event, context):
read file from key in the event from S3
decrypt file as your code shows
save decrypted file back to S3 likely in a different bucket or directory path
notify next process that the decrypted file is available.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.