amazon-web-services - 如何处理 Amazon CloudFront 中有空格的文件?

标签 amazon-web-services amazon-s3 cdn amazon-cloudfront

在我的 AWS S3 存储桶中,有很多文件名之间有空格。以下是其中 3 个可访问的文件 URL。

  • s3-us-west-amazonaws.com/debesh.com/images/natural+scenery+with+mountain+and+cloud.jpg
  • s3-us-west-2.amazonaws.com/debesh.com/images/natural+scenery+leaves+with+red+and+green+color.jpg
  • s3-us-west-2.amazonaws.com/debesh.com/images/natural+scenery+ant+in+the+middle+of+the+road+.jpg

  • 但是最近当我实现了 CloudFront CDN 分发时,源服务器是上面的 AWS S3 存储桶。

    我的云前域名:d37uawng2qmzgo.cloudfront.net

    现在,当我尝试使用我的 CloudFront 域名访问这些图像时。我收到一个错误页面。

    以下是由 CloudFront 域名替换的 URL:
  • d37uawng2qmzgo.cloudfront.net/images/natural+scenery+with+mountain+and+cloud.jpg
  • d37uawng2qmzgo.cloudfront.net/images/natural+scenery+leaves+with+red+and+green+color.jpg
  • d37uawng2qmzgo.cloudfront.net/images/natural+scenery+ant+in+the+middle+of+the+road+.jpg

  • 我发现问题在于文件名之间的空格。

    CloudFront CDN 无法识别文件名之间的 + 符号(即空格)。

    当我将“+”转换为“%20”时 ,它正在正确显示图像。
  • d37uawng2qmzgo.cloudfront.net/images/natural%20scenery%20with%20mountain%20and%20cloud.jpg
  • d37uawng2qmzgo.cloudfront.net/images/natural%20scenery%20leaves%20with%20red%20and%20green%20color.jpg
  • d37uawng2qmzgo.cloudfront.net/images/natural%20scenery%20ant%20in%20the%20middle%20of%20the%20road%20.jpg

  • 但问题是我的 AWS S3 存储桶中有很多文件,例如上述 3 个文件,而且我无法将 + 号更改为 %20 号。

    那么谁能建议我一种方法来处理这些文件名之间的这些空格 ?

    或者 AWS CloudFront 是否提供任何工具来处理此类文件命名问题?

    最佳答案

    我注意到 CloudFront 确实处理了 +现在在网址中。所以如果你仍然有分发版,这个 URL 应该可以工作:

    https://d37uawng2qmzgo.cloudfront.net/images/natural+scenery+with+mountain+and+cloud.jpg

    但是,如果有 + s 中的原始文件名,它们需要转换为 %2B用于 CloudFront URL。

    关于amazon-web-services - 如何处理 Amazon CloudFront 中有空格的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33759479/

    相关文章:

    MySQL - 适用于 AWS RDS 和 RR 支持的最佳内部错误处理技术

    node.js - DynamoDB 导致 Node/Lambda 中的模块初始化错误

    amazon-web-services - AWS CodePipeline 队列

    python - SSM 向 EC2 实例发送命令失败

    hadoop - 新创建的 S3 目录的时间戳为 1969-12-31

    logging - 获取特定 S3 对象的下载计数

    php - 亚马逊 S3 : What are considered PUT/COPY/POST/LIST request?

    Azure CDN 默认文档index.html

    amazon-s3 - cloudfront/s3 不使用缓存控制

    jQuery ssl 问题 - 为什么我在响应中看到 hwcdn.net?