我正在创建签名的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 URLThen, 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!
更多推荐
发布评论