我在s3上为我的网站运行静态托管.例如.www.somedomain.com指向S3桶.
我的api有一个子域api.somedomain.com,但处理跨域问题一直很烦人.我想映射www.somedomain.com/api/... - > api.somedomain.com/...但是没有完全重定向(301),因为我希望能够发布.
我知道Cloudfront允许这种行为,但由于我不需要CDN,因此它有点过分.
我已经获得了使用301重定向的路由规则,但无论如何要配置s3将我的请求传递给ec2?谢谢!
刚开始使用 node.js aws 客户端生成一个预先签名的 url 并将其发送到浏览器供用户上传文件,但我收到以下消息:
SignatureDoesNotMatch 我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
我参考了很多链接,看起来很基本,但我似乎失败了
https://github.com/aws/aws-sdk-js/issues/251
使用 Meteor、jQuery 和 AWS SDK 将浏览器直接上传到 S3
https://forums.aws.amazon.com/thread.jspa?messageID=556839
要么,我完全愚蠢,要么sdk真的很难用
节点:
var putParams = {
Bucket: config.aws.s3UploadBucket,
Key: filename,
ACL: 'public-read',
Expires: 120,
Body: '',
ContentMD5: 'false'
};
s3.getSignedUrl('putObject', putParams, function (err, url) {
if (!!err) {
console.error(err);
res.json({error: ''});
return;
}
res.json({
'awsAccessKeyId': config.aws.accessKeyId,
's3bucket': config.aws.s3UploadBucket,
's3key': filename,
's3policy': s3policy.policy,
's3signature': s3policy.signature,
'url': url
});
});
Run Code Online (Sandbox Code Playgroud)
客户:
var fd = new FormData();
fd.append('file', file);
return new RSVP.Promise(function(resolve, reject) {
$.ajax({ …Run Code Online (Sandbox Code Playgroud)