Node.js 如何签署从外部服务器执行的S3请求
我有我的RESTapi服务器,我在上面存储AWS公钥/密钥。我还存储客户机公钥/密钥客户机是我创建的用户-它有权发出CORS请求 我有我的外部服务器,它将文件直接上传到S3存储桶。但我不想在上面存储AWS凭据——我想在上传之前调用主服务器对请求进行签名,然后直接将文件上传到s3 目前,我在外部服务器上使用aws sdk,如下所示:Node.js 如何签署从外部服务器执行的S3请求,node.js,amazon-web-services,amazon-s3,Node.js,Amazon Web Services,Amazon S3,我有我的RESTapi服务器,我在上面存储AWS公钥/密钥。我还存储客户机公钥/密钥客户机是我创建的用户-它有权发出CORS请求 我有我的外部服务器,它将文件直接上传到S3存储桶。但我不想在上面存储AWS凭据——我想在上传之前调用主服务器对请求进行签名,然后直接将文件上传到s3 目前,我在外部服务器上使用aws sdk,如下所示: var aws = require('aws-sdk'); aws.config.update({ "accessKeyId": process.env.A
var aws = require('aws-sdk');
aws.config.update({
"accessKeyId": process.env.AMAZONS3_ACCESSKEY_ID,
"secretAccessKey": process.env.AMAZONS3_ACCESSKEY,
"region": process.env.AMAZONS3_REGION_CLOUD,
});
var s3 = new aws.S3({ params: { Bucket: 'myCustomBucket' } });
s3.putObject(...);
现在我需要更改,以便外部服务器使用一些S3参数调用主服务器,它将返回签名密钥或类似的内容,并使用它上载文件
那么,主服务器上的端点应该是什么样子的呢?中的哪些参数应该使用,以及如何生成符号?
然后,我如何使用该标志从外部服务器发出请求 在“创建预签名url”部分下面查看一下
// Get a command object from the client and pass in any options
// available in the GetObject command (e.g. ResponseContentDisposition)
$command = $client->getCommand('GetObject', array(
'Bucket' => $bucket,
'Key' => 'data.txt',
'ResponseContentDisposition' => 'attachment; filename="data.txt"'
));
// Create a signed URL from the command object that will last for
// 10 minutes from the current time
$signedUrl = $command->createPresignedUrl('+10 minutes');
echo file_get_contents($signedUrl);
// > Hello!
在一台服务器上创建一个put而不是get命令,将该命令传递给将创建预签名url的主服务器。将其传递回外部服务器以执行