【发布时间】:2023-02-24 03:47:04
【问题描述】:
我从以下函数获取 S3 存储桶(.opus 文件)的 presignedUrl:
function Get Recording URL(bucket, file Path, access Token) {
AWS.config.update({ accessKeyId: accessToken, secretAccessKey: accessToken, signatureVersion: 'v4', region: 'eu-west-2' }); const s3 = new AWS.S3(); const params = { Bucket: bucket, Key: filePath, Expires: 60000 } console.log("Bucket:",bucket); console.log("Filepath:",filePath); console.log("AccessToken:",accessToken); const url = s3.getSignedUrl('getObject', params) console.log("URL:", url); return url;}
它可以很好地生成 URL,但是当我浏览它时,我收到消息:
我将 accessKeyId 和 secretAccessKey 设置为相同的值 (accessToken),我认为这可能是问题所在?我正在使用 Cognito 并像这样登录:
try { console.log("Auth", Auth); const user = await Auth.signIn(this.state.username, this.state.password); console.log(user); this.props.auth.setAuthStatus(true); this.props.auth.setUser(user); this.props.history.push("/SearchScreen"); }catch(error) { let err = null; !error.message ? err = { "message": error } : err = error; this.setState({ errors: { ...this.state.errors, cognito: err } }); } };然后使用 user.signInUserSession.getAccessToken().getJwtToken() 获取令牌。我应该使用另一个令牌吗?
【问题讨论】: