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

查看:144
本文介绍了如何比较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天全站免登陆