可以通过 S3 rest API 访问的有效 S3 密钥名称是什么? [英] What are valid S3 key names that can be accessed via the S3 rest API?

查看:20
本文介绍了可以通过 S3 rest API 访问的有效 S3 密钥名称是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 AWS 文档中,我了解到:

From the AWS docs, I understand that:

  • S3 密钥名称可以是任何 UNICODE 名称
  • 1024 个字符
  • 使用 GET OBJ 时,我需要对密钥名称进行 URL 编码才能访问它.

然而,这些规则似乎过于宽松.

However, these rules seem too permissive.

例如,如果我创建一个名为../../d"的密钥,当我尝试使用 GET OBJECT API 访问它时会发生 400 错误.有趣的是,我访问../d"没有问题.

For instance, if I make a key called '../../d', a 400 ERROR occurs when I attempt to access it with the GET OBJECT API. Interestingly, I have no problem accessing '../d'.

是否有文件说明什么是合法的,什么是不合法的?

Is there a document specifying what is and is not legal?

推荐答案

根据 AWS S3 文档:

虽然您可以在对象键名称中使用任何 UTF-8 字符,但以下键命名最佳做法有助于确保与其他应用程序的最大兼容性.每个应用程序可能会以不同的方式解析特殊字符.以下指南可帮助您最大限度地遵守 DNS、网络安全字符、XML 解析器和其他 API.

Although you can use any UTF-8 characters in an object key name, the following key naming best practices help ensure maximum compatibility with other applications. Each application may parse special characters differently. The following guidelines help you maximize compliance with DNS, web safe characters, XML parsers, and other APIs.

请在下面找到

以下字符集通常安全用于键名:

  • 字母数字字符:0-9 a-z A-Z
  • 特殊字符:!- _ .* ' ( )

关于分隔符(/")的注意事项

NOTE ABOUT THE DELIMITER ("/")

以下是有效对象键名称的示例:

The following are examples of valid object key names:

  • 4my-organization

  • 4my-organization

my.great_photos-2014/jan/myvacation.jpg

my.great_photos-2014/jan/myvacation.jpg

videos/2014/birthday/video1.wmv

videos/2014/birthday/video1.wmv

请注意,Amazon S3 数据模型是一种扁平结构:您创建一个存储桶,该存储桶存储对象.没有子桶或子文件夹的层次结构;但是,您可以像 Amazon S3 控制台那样使用键名前缀和分隔符来推断逻辑层次结构.

Note that the Amazon S3 data model is a flat structure: you create a bucket, and the bucket stores objects. There is no hierarchy of subbuckets or subfolders; however, you can infer logical hierarchy using keyname prefixes and delimiters as the Amazon S3 console does.

例如,如果您使用 Private/taxdocument.pdf 作为密钥,它将创建 Private 文件夹,其中包含 taxdocument.pdf.

e.g if you use Private/taxdocument.pdf as a key, it will create the Private folder, with taxdocument.pdf in it.

Amazon S3 支持存储桶和对象,Amazon S3 中没有层次结构.但是,对象键名称中的前缀和分隔符使 Amazon S3 控制台和 AWS 开发工具包能够推断层次结构并引入文件夹的概念.

Amazon S3 supports buckets and objects, there is no hierarchy in Amazon S3. However, the prefixes and delimiters in an object key name, enables the Amazon S3 console and the AWS SDKs to infer hierarchy and introduce concept of folders.


可能需要特殊处理的字符

密钥名称中的以下字符可能需要额外的代码处理,并且可能需要进行 URL 编码或引用为 HEX.其中一些是不可打印的字符,您的浏览器可能无法处理它们,这也需要特殊处理:


Characters That Might Require Special Handling

The following characters in a key name may require additional code handling and will likely need to be URL encoded or referenced as HEX. Some of these are non-printable characters and your browser may not handle them, which will also require special handling:

  • 与号(&")
  • 'At' 符号(@")
  • 冒号(:")
  • 逗号(,")
  • 美元($")
  • 等于(=")
  • 加号(+")
  • 问号(?")
  • ASCII 字符范围 00–1F 十六进制(0–31 十进制)和 7F(十进制 127.)
  • 分号(;")
  • 空格 - 在某些用途(尤其是多个空格)中可能会丢失重要的空格序列

您应该避免在键名中使用以下字符,因为为了在所有应用程序之间保持一致性,需要进行重要的特殊处理.

You should avoid the following characters in a key name because of significant special handling for consistency across all applications.

  • 反斜杠(")
  • 插入符号(^")
  • 重音符/反勾号(`")
  • 大于"符号(>")
  • 小于"符号(<")
  • 左花括号({")
  • 右花括号(}")
  • 右方括号(]")
  • 左方括号([")
  • '磅'字符(#")
  • 不可打印的 ASCII 字符(128–255 个十进制字符)
  • 百分比字符(%")
  • 引号
  • 波浪号(~")
  • 竖条/管道(|")

这篇关于可以通过 S3 rest API 访问的有效 S3 密钥名称是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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