PHP S3的预签名的URL没有SDK [英] php s3 pre signed url without sdk

查看:45
本文介绍了PHP S3的预签名的URL没有SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此类生成包含策略部分的直接上载表单.

I'm using this class to generate a direct upload form which includes the policy part.

https://www.designedbyaturtle.co.uk/2015/direct-upload-to-s3-using-aws-signature-v4-php/

上传正常,但我希望能够在网站上向用户显示网址中的文件,而不必将文件公开.

The uploads are working but I want to be able to display the file from the url for users on the site without making the files public.

我了解SDK为此提供了一种简单的方法,但我希望可以使用现有代码来完成此操作,因为这已经创建了该策略.我想知道从头开始创建此URL的哪些步骤?仅仅为了一个功能而包含整个ated肿的SDK似乎是多余的.

I understand the SDK has a simple method for this but I am hoping I can do it with the existing code as this already creates the policy. I'm wondering what are hte steps for creating this url from scratch? It seems excessive to include the entire bloated SDK for just one function.

推荐答案

创建一个S3预签名URL对于GET请求实际上非常容易.PUT相当容易,但是POST很复杂,并且需要一项策略.

Creating an S3 pre-signed URL is actually very easy for GET requests. PUT is fairly easy, but POST is complicated and requires a policy.

挑战在于创建签名代码.Amazon支持两个版本v2和v4.v2正在逐步淘汰.v4的编码有些复杂.

The challenge is creating the signing code. Amazon supports two versions v2 and v4. v2 is being phased out. v4 is somewhat complicated to code.

如果仅为GET请求创建预签名的URL,请编写自己的代码.除此之外,我强烈建议您使用SDK.

If you are only creating pre-signed URLs for GET requests, write your own code. For anything else, I seriously recommend using the SDK.

下面是指向源代码的链接,以使用不带AWS开发工具包的PHP使用S3V4对S3 URL进行预签名.

Below is a link to the source code to pre-sign an S3 URL using S3V4 using PHP without the AWS SDK.

S3LINK-V4.PHP

这篇关于PHP S3的预签名的URL没有SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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