簡體   English   中英

如何使用boto3從/向stdin / stdout流式傳輸到/從S3流式傳輸

[英]How to stream from/to stdin/stdout to/from S3 using boto3

我正在尋找幫助,找出如何使用boto3從stdin和stdout流式傳輸對象。 AWS S3 cp命令可以通過指定' - '作為文件名來實現,但查看boto3文檔我不明白如何。

對於STDOUT的對象,可以將S3對象作為流打開

s3 = boto3.client('s3')
s3.download_fileobj('your_bucket', 'your_key', sys.stdout)

STDIN上傳它幾乎是一樣的,但根據你想做什么,你可以讓你的生活更輕松(nb python 3 here`)

some_stuff = input('type something: ')
s3.put_object(**{
    'Bucket': 'your_bucket',
    'Key': 'your_key',
    'Body': some_stuff
})

這可能呢?

import sys
sys.stdin, sys.stdout

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM