如何比较 Amazon S3 对象的版本? [英] How to compare versions of an Amazon S3 object?

查看:28
本文介绍了如何比较 Amazon S3 对象的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Amazon S3 存储桶的版本控制很好,但我没有看到任何简单的方法来比较文件的版本 - 无论是通过控制台还是通过我找到的任何其他应用程序.

Versioning of Amazon S3 buckets is nice, but I don't see any easy way to compare versions of a file - either through the console or through any other app I found.

S3Browser 似乎有最好的版本支持,但没有可比性.

S3Browser seems to have the best versioning support, but no comparison.

有没有办法在 S3 上比较文件的版本,而无需下载两个版本并手动比较它们?

Is there a way to compare versions of a file on S3 without downloading both versions and comparing them manually?

--

我刚开始认为一些基本的自动化不应该太难,见下面的片段.但问题仍然存在:是否有任何工具可以正确支持这一点?这个脚本可能适合我,但不适用于非开发用户.

I just started thinking that some basic automation should not be too hard, see snippet below. Question remains though: is there any tool that supports this properly? This script may be fine for me, but not for non-dev users.

#!/bin/bash

# s3-compare-last-versions.sh

if [[ $# -ne 2 ]]; then
    echo "Usage: `basename $0` <bucketName> <fileKey> "
    exit 1
fi

bucketName=$1
fileKey=$2

latestVersionId=$(aws s3api list-object-versions --bucket $bucketName --prefix $fileKey --max-items 2 | json Versions[0].VersionId)
previousVersionId=$(aws s3api list-object-versions --bucket $bucketName --prefix $fileKey --max-items 2 | json Versions[1].VersionId)

aws s3api get-object --bucket $bucketName --key $fileKey --version-id $latestVersionId $latestVersionId".js"
aws s3api get-object --bucket $bucketName --key $fileKey --version-id $previousVersionId $previousVersionId".js"

diff $latestVersionId".js" $previousVersionId".js"

推荐答案

通过S3根本无法查看文件内容,所以通过S3肯定无法比较文件内容.您必须下载不同的版本,然后使用 diff 之类的工具进行比较.

You can't view file contents at all via S3, so you definitely can't compare the contents of files via S3. You would have to download the different versions and then use a tool like diff to compare them.

这篇关于如何比较 Amazon S3 对象的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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