Problem uploading empty files with upload_object

未关闭
#1,562 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
aws, python
领域
cloud

调研方向

报告的入口点是 upload_object 和 upload_object_via_stream;首先使用 S3 驱动复现空文件情况,并比较 AWS S3、MinIO 和 NetApp StorageGRID 之间的行为。由于 issue 中没有指定源文件或测试,请先找到上传实现及其测试。完成标准是 upload_object 能够处理带有元数据的空文件,同时不会生成重复的 Host 标头,也不会破坏提供商兼容性。

由索引模型根据 Issue 内容生成。

描述

Summary

Using upload_object to upload an empty file returns response:
400 - Bad Request: too many Host headers

Detailed Information

Python 3.6.8
Libcloud: 3.3.1
OS: rhel 7.9

I use libcloud to upload objects to 3 providers - aws s3, minio & netapp storageGrid, I use the s3 driver for all of them. upload_object function works fine except when I try to upload an empty file (I sometimes need to store just meta-data with a specific object name for later use). When trying to upload an empty file I get the response:

status: 400
reason: 'Bad Request: too many Host headers'

If I add anything to the file's content it uploads successfully with the meta-data, so its not a problem with permissions/path in s3 or something like that. I also tried without the meta-data, but that didn't work either.
I tried using upload_object_via_stream and found the following code works:

with io.BytesIO() as iterator:
    driver.upload_object_via_stream(iterator=iterator,
                                    container=container,
                                    object_name=objName,
                                    extra=extra)

This code uploads a 0 bytes file successfully to aws s3 & minio, but not to netapp's storageGrid (so unfortunately I can't use it).
I think it's a limitation of storageGrid's multi-part upload and not some other storage restriction (we have existing empty objects on storageGrid, but those were uploaded using jclouds).

I think using upload_object will be the best solution for all 3 providers, but I don't understand why it's not uploading empty files and would appreciate help with this. Thanks!

Reproduce
  1. touch ~/test-empty.txt
  2. Use upload_object to upload test-empty.txt
主要语言
Python
星标
2.1k
派生
935
平均合并
5 天 3 小时
30 天内合并 PR
15

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/libcloud 的其他 Issue

查看 apache/libcloud 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。