php - 从浏览器直接上传到S3(亚马逊)和https麻烦

标签 php amazon-web-services https amazon-s3 amazon

我创建了一个页面,用户可以从中上传他们的文件。此代码片段将这些文件发送到我的 Amazon S3 存储桶。

<form action="https://BUCKET.s3-eu-west-1.amazonaws.com/" method="post" enctype="multipart/form-data">
  <input type="hidden" name="awsAccessKey" value="ACCESS_KEY">
  <input type="hidden" name="awsSecretKey" value="SECRET_KEY"> 
  <input type="hidden" name="acl" value="private"> 
  <input type="hidden" name="policy" value="POLICY">
  <input type="hidden" name="signature" value="SIGNATURE">
  <input type="hidden" name="Content-Type" value="">
  <!-- Include any additional input fields here -->

  File to upload to S3: 
  <input name="file" type="file"> 
  <br> 
  <input type="submit" value="Upload File to S3"> 
</form> 

一切正常,但我遇到了 https 问题。主要浏览器不信任 s3-eu-west-1.amazonaws.com 并显示有关不可信连接的安全消息。

我将 HTTPS 连接更改为 HTTP,这样我的客户就不会遇到任何问题。有人对如何解决此问题有任何想法吗?

最佳答案

很可能您的存储桶名称中有一个点。 Amazon 的 S3 通配符证书仅适用于一级子域,因此 bucket.s3-eu-west-1.amazonaws.com 可以,但 bucket.bucket.s3-eu-west- 1.amazonaws.com 不是。改用这个:

https://s3-eu-west-1.amazonaws.com/BUCKET/

关于php - 从浏览器直接上传到S3(亚马逊)和https麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26810062/

相关文章:

php - md5 和 hash 的问题

amazon-web-services - 无法关闭 AWS 上的 ElasticSearch 索引?

spring-boot - 如何让我的 Spring Boot 微服务使用 HTTPS 运行?

java - 确定以两种方式 ssl 使用哪个证书

php - Wordpress:逐月获取帖子,布局问题

php - 循环内的多个文件验证

amazon-web-services - 我可以对我的 AWS 支出设置硬性限制吗?

ssl - Poco HTTPRequest中如何传递数据

php - 缺少 Google API autoload.php

amazon-web-services - Terraform:日志驱动程序 awslogs 选项 'awslogs-group' 包含无效字符