我试图让S3 HTML上传工作,我试图硬编码定义密钥名称,而不是使用${filename}
。这是由我的API服务器控制的,但是当我指定带有文件夹分隔符的密钥并将其上传时,它会转换为%2F
的html实体。
所以我有这个POST政策:
{
"expiration": "2017-01-01T00:00:00Z",
"conditions": [
{"bucket": "mybucket"},
{"key": "i/1/1.png"},
{"acl": "public-read"},
{"Content-Type": "image/png"},
["content-length-range", "0", "1048576"]
]
}
使用HTML表单:
<html>
<head>
<title>S3 POST Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form action="https://mybucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
<input type="hidden" name="key" value="i/1/1.png">
<input type="hidden" name="AWSAccessKeyId" value="AWS_ACCESS_KEY_ID">
<input type="hidden" name="acl" value="public-read">
<input type="hidden" name="policy" value="base64 policy">
<input type="hidden" name="signature" value="signature">
<input type="hidden" name="Content-Type" value="image/png">
<!-- 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>
</body>
</html>
上传文件时,文件名最终为:
https://mybucket.s3.amazonaws.com/i%2F1%2F1.png
所以问题是,如何让/
成为文字文件夹分隔符?
答案 0 :(得分:0)
%2F
和/
都是有效的文件夹分隔符。