gpt4 book ai didi

android - 无法从 Amazon S3 下载具有特殊字符的文件

转载 作者:IT老高 更新时间:2023-10-28 23:01:10 26 4
gpt4 key购买 nike

我一直在尝试从 Amazon S3 下载以特殊字符结尾的文件。 enter image description here

由于 Base64 编码,文件名以“=”结尾。现在我正在尝试下载此文件,但收到错误消息,

指定的键不存在。 (服务:Amazon S3;状态代码:404;错误代码:NoSuchKey;

enter image description here

我尝试了对字符串进行 URL 编码。所以现在“=”变成了“%3D”,我仍然收到同样的错误。但是,如果我从文件名中删除“=”,我就可以毫无问题地下载文件。但这是一个通用文件,也可以从 iOS 访问。

注意:即使文件名中包含“=”,iOS Amazon SDK 也能正常工作。该问题仅在 Android SDK 中存在。

最佳答案

根据AWS documentation

Safe Characters

The following character sets are generally safe for use in key names:

Alphanumeric characters [0-9a-zA-Z]

Special characters !, -, _, ., *, ', (, and )

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:

Ampersand ("&")

Dollar ("$")

ASCII character ranges 00–1F hex (0–31 decimal) and 7F (127 decimal.)

'At' symbol ("@")

Equals ("=")

Semicolon (";")

Colon (":")

Plus ("+")

Space – Significant sequences of spaces may be lost in some uses (especially multiple spaces)

Comma (",")

Question mark ("?")

所以它确认您“=”需要特殊处理,如果您将最后一个“=”字符替换为另一个安全字符会更好以避免问题...

请尝试将“=”改为“=


在 iOS 上,没有问题,我希望它可能与 Android 环境有关。

您可能会注意到,由于 SH 或 BASH 或 ANDROID shell 环境执行,某些字符也可能被禁止,另请注意,某些磁盘格式选项(普通 android 外部存储卡上的 FAT32)也可能代表文件名中禁止某些字符的因素。

如果你看一下 here尤其是@kreker 的回答:

According to wiki and assuming that you are using external data storage which has FAT32.

Allowable characters in directory entries

are

Any byte except for values 0-31, 127 (DEL) and: " * / : < > ? \ | + , . ; = [] (lowcase a-z are stored as A-Z). With VFAT LFN any Unicode except NUL

您会注意到 = 不是 android FAT32 分区上允许的字符...

我预计 Android 会将 = 视为受限字符,您可以尝试使用 \= 对其进行转义或在代码中的文件名中添加引号...

带有副本的示例:

cp filename=.png mynewfile=.png #before


cp "filename=.png" "mynewfile=.png" #after

“VCS...=.png”

如果这些技巧都不起作用,您必须在创建这些文件时更改文件名以删除“=”。

问候

关于android - 无法从 Amazon S3 下载具有特殊字符的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47649185/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com