缩短S3签名的网址(Shorten S3 signed url)

编程入门 行业动态 更新时间:2024-10-10 03:24:36
缩短S3签名的网址(Shorten S3 signed url)

我正在创建签名的URL并将它们发送到外部系统供以后使用。 不幸的是,有一些长度参数不允许传递极长的字符串。 最近,似乎签名的URL被重新格式化和扩展,随后打破了我的应用程序。

是否有一些方法可以从S3生成较短的URL? 由于多种原因,我不希望依赖第三方URL缩短服务(这是对URL生成的额外请求,它增加了一个失败点)。

I'm creating signed URLs and sending them to an external system for later use. Unfortunately there are some length parameters that do not allow extremely long strings to be passed along. Recently, it appears that signed URLs were reformatted and extended which subsequently broke my app.

Is there some method for generating a shorter URL from S3? I would prefer not to rely on a third party URL shortening service for a number of reasons (it's an extra request at URL generation and it adds a point-of-failure).

最满意答案

您可以直接在Amazon S3中构建一个非常简单的URL缩短器

打开静态网站托管 。 这会给你一个URL来访问你的存储桶,例如: mybucket.s3-website-ap-southeast-2.amazonaws.com 在S3中用一个“简称”创建一个零长度的对象 ,例如pic1.jpg 将元数据添加到零长度对象: 重点: Website Redirect Location 值:长URL

然后,当你访问零长度的对象时(例如mybucket.s3-website-ap-southeast-2.amazonaws.com/pic.jpg ),它实际上会重定向到存储在元数据中的长URL。

简单,无需数据库!

You can build a very simple URL Shortener directly within Amazon S3:

Turn on static website hosting. This will give you a URL to access your bucket, eg: mybucket.s3-website-ap-southeast-2.amazonaws.com Create a zero-length object in S3 with a 'short name', eg pic1.jpg Add metadata to the zero-length object: Key: Website Redirect Location Value: The Long URL

Then, when you access the zero-length object (eg mybucket.s3-website-ap-southeast-2.amazonaws.com/pic.jpg) it will actually redirect to the Long URL stored in the metadata.

Simple, with no database required!

更多推荐

本文发布于:2023-04-29 01:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334434.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   Shorten   url   signed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!