AWS S3 API/CLI-隐藏文件的旧版本 [英] AWS S3 API/CLI - hide older versions of a file

查看:78
本文介绍了AWS S3 API/CLI-隐藏文件的旧版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在我的S3存储桶上启用了 versioning ,不会丢失/覆盖任何数据.

I have enabled versioning on my S3 bucket to not lose/overwrite any data.

但是现在当我使用CLI时,它会返回重复文件:

However now when I use the CLI it returns duplicates files:

aws s3 ls s3://my-bucket

# returns:
2021-01-25 10:54:02      49062 my_file.csv
2021-01-26 11:40:13      49062 my_file.csv 

我在API/CLI中看不到任何可选标志来仅显示文件的最新版本,因此我想知道如何正确使用版本控制而不看到重复的文件. https://docs.aws.amazon.com/cli/latest/reference/s3api/list-objects-v2.html

I could not see any optional flags in the API/CLI to only show the latest version of a file, so I am wondering how to properly work with versioning without seeing duplicate files. https://docs.aws.amazon.com/cli/latest/reference/s3api/list-objects-v2.html

推荐答案

事实证明重复项不是由于版本控制,而是因为某些文件带有空白:

It turns out that the duplicates were not because of versioning but rather because some files has a white space attached:

aws s3api list-objects --bucket my_bucket

returns:
        {
            "Key": "my_file.csv",
            "LastModified": "2021-01-15T15:44:03+00:00",
            "ETag": "\"bdc14cb0f1adf95aadf1620fd579ffe4\"",
            "Size": 18649,
            "StorageClass": "STANDARD",
        },
        {
            "Key": "my_file.csv ", # HERE is a white space in the name
            "LastModified": "2021-01-26T11:40:07+00:00",
            "ETag": "\"bdc14cb0f1adf95aadf1620fd579ffe4\"",
            "Size": 18649,
            "StorageClass": "STANDARD",
        },

感谢John向我指出该API CLI调用!

thanks John for pointing me towards that API CLI call!

这篇关于AWS S3 API/CLI-隐藏文件的旧版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆