如何解决AWS amplify Storage.put不喜欢星号吗?
有人知道为什么AWS Amplify Storage.put不喜欢星号吗?
文件名可以使用星号-> https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
但是当我尝试以下操作(示例)时:
import React,{ useEffect,useState } from 'react';
import Amplify,{ API,Storage } from 'aws-amplify';
import { withAuthenticator,AmplifySignOut,AmplifySignIn,AmplifySignUp } from '@aws-amplify/ui-react';
import { MdSend } from 'react-icons/md';
import awsExports from "./aws-exports";
import './App.css';
Amplify.configure(awsExports);
const App = () => {
const [name,setName] = useState('')
const [file,setFile] = useState('')
const onChange = (e) => {
var stringName = "andy_2020_something*test_hello*description.mp4";
e.preventDefault()
if (e.target.files[0] !== null) {
setFile(e.target.files[0])
setName(stringName)
}
}
const onSubmit = (e) => {
e.preventDefault()
if (file) {
Storage.put(name,file,{
contentType: file.type,})}}
return (
<div className='video-uploader'>
<form onSubmit={(e) => onSubmit(e)}>
<p>
<label className='select-label'>Select video: </label>
</p>
<p>
<input
className='video-input'
type='file'
id='file-input'
accept='image/*,video/*'
onChange={(e) => onChange(e)}
/>
</p>
<button type='submit' className='btn'>
Submit <MdSend className='btn-icon' />
</button>
</form>
</div>)}
export default withAuthenticator(App)
我得到一个403的回复:
SignatureDoesNotMatch
我们计算出的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
(响应包含更多,但大多数看起来似乎不太有用)。文件名的编码可能是:andy_2020_something%2atest_hello%2adescription.mp4
但是,如果我从文件名中删除星号,则请求将成功。
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。