gpt4 book ai didi

node.js - 获取 SignatureDoesNotMatch : null error while uploading images to DigitalOcean Spaces using multers3 node. js

转载 作者:行者123 更新时间:2023-12-03 12:18:18 33 4
gpt4 key购买 nike

Error: code:'SignatureDoesNotMatch'
extendedRequestId:undefined
message:null
name:'SignatureDoesNotMatch'
region:null
// Load dependencies
const aws = require('aws-sdk');
const express = require('express');
const multer = require('multer');
const multerS3 = require('multer-s3');

const app = express();

// Set S3 endpoint to DigitalOcean Spaces
const spacesEndpoint = new aws.Endpoint('fra1.digitaloceanspaces.com');
const s3 = new aws.S3({
endpoint: spacesEndpoint,
accessKeyId: '*************',
secretAccessKey: '**********************************'
});

// Change bucket property to your Space name
const upload = multer({
storage: multerS3({
s3: s3,
bucket: 'bucket',
acl: 'public-read',
key: function (request, file, cb) {
console.log(file);
cb(null, file.originalname);
}
})
}).array('upload', 1);

// Views in public directory
app.use(express.static('public'));

// Main, error and success views
app.get('/', function (request, response) {
response.sendFile(__dirname + '/public/index.html');
});

app.get("/success", function (request, response) {
response.sendFile(__dirname + '/public/success.html');
});

app.get("/error", function (request, response) {
response.sendFile(__dirname + '/public/error.html');
});

app.post('/upload', function (request, response, next) {
upload(request, response, function (error) {
if (error) {
console.log(error);
return response.redirect("/error");
}
console.log('File uploaded successfully.');
response.redirect("/success");
});
});

app.listen(3001, function () {
console.log('Server listening on port 3001.');
});
试试这个 blog digital ocean 空间示例

最佳答案

我遇到了同样的问题,唯一有帮助的是重置 key

关于node.js - 获取 SignatureDoesNotMatch : null error while uploading images to DigitalOcean Spaces using multers3 node. js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65490170/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com