如何获取 S3 存储桶上的最后一笔交易?

发布于 2024-08-17 03:16:01 字数 176 浏览 3 评论 0原文

我是 S3 AWS SDK 的初学者。并在我的项目中遇到问题。

我想获取当前上传的文件的上传或下载大小。实际上,我的应用程序的功能是将内容直接从客户端浏览器上传到 Amazon S3。但是,如果数据传输中断并且引发异常,那么我无法跟踪已传输的文件数据量。

如果有人有解决办法,请回复。

谢谢

Am a beginner of S3 AWS SDK. and getting problem in my project.

I want to get uploaded or downloaded size of file which is currently uploaded. Actually the functionality of my application is that it will upload contents directly from client browser to Amazon S3. But if transfer of data interrupted and if exception is raised then i cant track that how much data of file has be transfered.

If anybody has a solution, please reply.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

真心难拥有 2024-08-24 03:16:01

首先,您在 S3 中找不到“最后一笔交易”功能。
S3 不是事务性的,它是一个巨大的哈希表。如果您的上传失败,即使上传失败,该项目也不会存在于您的存储桶中。

话虽如此,最好的选择是使用 Flash 或 Silverlight 上传文件。这样您就可以访问客户端上的文件大小,并可以在上传文件时添加适当的元标记。它还允许您给出准确的进度条。

查看此示例。

First of all you will not find a "last transaction" functionality in S3.
S3 is not transactional, it is a giant hashtable. If your upload fails the item will not exist in your bucket, even if it failed half way though.

Having said that your best option here is to use Flash or Silverlight to upload the file. This way you have access to the file size on the client and can added the appropriate meta tags when uploading the file. It also allows you to give an accurate progress bar.

Have a look at this example.

浅紫色的梦幻 2024-08-24 03:16:01

您可以使用ls命令根据日期获取存储桶中的文件列表:

aws s3 ls s3://mybucket --recursive

如果您使--recursive | sort,结果将按日期排序。您可以选择结果中的最后一项来获取最后修改/上传的对象。

You can use use ls command to get the file list in a bucket based on the date:

aws s3 ls s3://mybucket --recursive

if you make --recursive | sort, the result will be ordered by date. You can pick the last item in the result to get the last modified/uploaded object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文