我的想法不多了,我将如何解决这个问题
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
Run Code Online (Sandbox Code Playgroud)
当我在 ec2 实例(生产)中运行我的节点 js 代码但在我的本地主机中完美运行时。
我实际做的是使用 node js API https://grokonez.com/aws/node-js-restapis-upload-file-to-amazon-s3-using-express-multer-aws-sdk上传 img 到 s3 存储桶
var stream = require('stream');
const s3 = require('../config/s3.config.js');
exports.doUpload = (req, res) => {
const s3Client = s3.s3Client;
const params = s3.uploadParams;
params.Key = Date.now() +'_'+req.file.originalname
params.Body = req.file.buffer;
s3Client.upload(params, (err, data) => {
if (err) {
res.status(500).json({error:"Error -> " + err});
}
res.json({message: 'File uploaded successfully! -> keyname = ' + …Run Code Online (Sandbox Code Playgroud)