python-3.x - 如何使用 python boto3 在 aws S3 中创建文件

标签 python-3.x amazon-web-services amazon-s3 boto3

我想使用 python 在 AWS s3 中创建一个空文件。

我正在使用 boto3 和 python。

我想知道除了put方法之外还有什么方法可以在s3中创建文件吗?

最佳答案

假设你真的想要一个零字节的文件,你可以这样做:

import boto3

s3 = boto3.client('s3')

s3.put_object(
    Bucket='mybucket',
    Key='myemptyfile'
)

注意缺少 Body参数,导致一个空文件。

关于python-3.x - 如何使用 python boto3 在 aws S3 中创建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58735100/

相关文章:

python-3.x - Pyppeteer RequestSetIntercept函数: coroutine was never awaited

amazon-web-services - AWS : How to copy multiple file from local to s3?

java - 与 Alexa 的意外通信问题

python - 摆脱 'Can' t 绘制到关闭窗口的错误

python - Del 循环内的变量

python - 使用不同的参数初始化多个变量

ruby-on-rails - 要在 AWS Linux EC2 实例上安装以访问 Postgres RDS 的 Postgres 包

javascript - 如何解决 AWS 错误 : "The difference between the request time and the current time is too large" front-end only?

amazon-web-services - 无法使用已配置的 SQS 策略验证 Cloudformation 中 S3 到 SQS 通知的以下目标配置

amazon-web-services - 从 s3 加载 gensim 不起作用