r - 无法从 R 在 S3 存储桶中写入 csv 文件
问题描述
我正在尝试使用以下代码将 csv 文件写入 Amazon S3 存储桶
s3write_using(gene_read_counts, FUN = write.csv, object = "gene_read_counts_test.csv", bucket = "test-bioinformatics-dev-bkt/research/bioinformatics/colo_final/data/processed/colorectal", row.names=FALSE)
我收到以下错误
文件大小为 71619789。考虑设置“multipart = TRUE”。parse_aws_s3_response(r, Sig, verbose = verbose) 中的错误:禁止 (HTTP 403)。
解决方案
在查看错误时,可能有两个方面。
似乎错误建议在上传大文件时使用 AWS-S3 分段上传。分段上传提供更快、更灵活的上传到 Amazon S3。它可以通过
- 将对象/文件分成小块。
CreateMultipartUpload
使用S3 API上传初始化。- 使用分段上传上传部分对象。使用
UploadPartCopy
S3 API 的操作 - 完成分段上传。使用
CompleteMultipartUpload
S3 API 的操作。 - 同时必须执行
AbortMultipartUpload
如果任何部分上传失败。使用AbortMultipartUpload
,任何先前上传的部分所占用的存储空间都将被释放。
请参阅以下 AWS 文档。 https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html https://docs.aws。 amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html
Forbidden (HTTP 403) 错误提示权限被拒绝。在这种情况下,如果用户有权访问 S3 对象,请检查 IAM 角色。
由于您使用“R”语言在 S3 中编写文件。我建议使用Put_Object
函数并multipart = TRUE
在函数中设置部分上传文件。
你可以使用下面的代码
put_object(filename, object, bucketname, multipart = TRUE, acl = c("private",
"public-read", "public-read-write", "aws-exec-read", "authenticated-read",
"bucket-owner-read", "bucket-owner-full-control"), headers = list(), ...)
当您 multipart = TRUE
在上述函数中说时,它将创建所提供对象的部分或块并在 S3 中部分上传。
推荐阅读
- mysql - 使用 mysqlsh 时如何抑制列标题输出?
- php - 用于排除特殊模式的正则表达式
- node.js - 无法弄清楚如何让引导表与电子渲染器一起使用
- wordpress - Http 到 Https Wordpress 后重定向过多
- c++ - 识别不同线程同时使用的线程不安全数据结构
- angular - Angular - 绑定大量数据时 IE 没有响应问题
- excel - 特定 VBA 函数(例如 SendKeys)的潜在 Google 脚本等效项
- sql - 为什么我收到 TADOQuery 选择语句错误?
- sql - SQL 这个查询的另一种解决方案?
- python - 查找python打印功能