python - 使用预签名 URL PUT 方法上传文件不起作用 Python 请求
问题描述
我正在尝试读取驻留在 s3 存储桶内的文件并通过预签名的 url 将其上传到另一个 s3 存储桶。我尝试上传单个文件,效果很好。但是,如果我尝试上传存储桶中的文件列表,则无法上传数据。它始终将响应代码设为 200,但数据会上传到目标 s3 位置,尤其是大文件。
我的python代码如下。
import boto3
import requests
from io import BytesIO
for file in file_list:#list of file names in the bucket
pre_url=getPreSinedUrl()#for each file method will return a separate pre-signed url to upload file
data_in_bytes = s3.get_object(Bucket="my-bucket", Key=file)['Body'].read()
res = requests.put(pre_url, data=BytesIO(data_in_bytes), headers=my_header)
print(res.status_code)
为什么没有上传 s3 中的文件有什么帮助?
解决方案
推荐阅读
- google-apps-script - 使用脚本编辑器在设置时间间隔上更新 Vlookup 公式
- javascript - 在 Google Earth Engine 的 Java 编辑器中创建重复第一个元素并添加 _1 _2 到 _n 的字符串列表
- appium - 我用Appium连接手机app,但是出现权限错误
- c# - 如何根据行单元格值在 GuiGridView 中选择一行?
- c++ - 一个服务器类,通过传递服务器生成的值,在线程中运行任何函数
- python - 想知道我用海龟绘制棋盘的python代码发生了什么?有什么帮助吗?
- java - 我应该如何处理 IOException?
- html - 是否有一个 Visual Studio 快捷方式可以在行的开头和结尾给出多行 html 标记?
- c++ - 我非常简单的 CPP 代码无法正常工作
- c - 声明变量的顺序有区别吗?