将 API 文件加载到 S3 中的子文件夹时粘合作业失败
我对此很陌生。 我使用 python 脚本创建了一个简单的 Glue 作业,用于发送 API 请求并将数据加载到 S3 中。将数据加载到顶部 S3 存储桶 (s3://my-bucket) 时,它工作正常,但当我更改目标目录以将文件加载到 S3 的子目录 (s3://my-bucket/log-data) 时,作业失败。 以下脚本可以将文件 mydata.txt 加载到存储桶中。
import request
import boto3
URL = "https://jsonplaceholder.typicode.com/todos/1"
r = requests.get(url = URL)
s3_client = boto3.client('s3',region_name='eu-west-2')
s3_client.put_object(Body=r.text, Bucket='my-bucket', Key='mydata.txt')` '
当我更改代码的最后一行以将文件加载到 S3 存储桶的子目录中时,
s3_client.put_object(Body=r.text, Bucket='my-bucket/log-data', Key='mydata.txt')
任何建议将不胜感激。 谢谢,
I'm new to this.
I've created a simple Glue job with python script that send API request and load data into S3. When loading data into the top S3 bucket (s3://my-bucket) it works fine but the job fails when I change the target directory to load files into subdirectory of S3 (s3://my-bucket/log-data).
the following script works and load file mydata.txt into the bucket.
import request
import boto3
URL = "https://jsonplaceholder.typicode.com/todos/1"
r = requests.get(url = URL)
s3_client = boto3.client('s3',region_name='eu-west-2')
s3_client.put_object(Body=r.text, Bucket='my-bucket', Key='mydata.txt')` '
when I change the last line of the code to load file into the subdirectory of S3 bucket
s3_client.put_object(Body=r.text, Bucket='my-bucket/log-data', Key='mydata.txt')
Any advice will be much appreciated.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将前缀添加到
put_object
中的Key
argTry adding the prefix to the
Key
arg input_object