请帮助我。
我的流程:
使用文件 Tempate -> Code (Exceljs) -> 输出新文件
模板文件:
源代码:
worksheet.pageSetup.horizontalCentered = true
worksheet.pageSetup.verticalCentered = true
Run Code Online (Sandbox Code Playgroud)
但是文件输出:
我在本地主机上进行了测试,然后在 s3 上进行了检查,发现创建了一个新文件。但是在Lambda上测试时,虽然没有报错,但是S3上却没有文件。s3.upload(params).promise()的日志也不会显示。
var fs = require('fs');
var AWS = require('aws-sdk');
exports.handler = async (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false
try {
AWS.config.update({
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey
});
var s3 = new AWS.S3();
var path = 'myfile.txt';
var file_buffer = fs.readFileSync(path);
console.log(file_buffer);
var params = {
Bucket: 'bucket-dev',
Key: '2222.txt',
Body: file_buffer
};
console.log("1111");
s3.upload(params).promise()
.then(function(data) {
console.log("Successfully uploaded to");
callback(null, "All Good");
})
.catch(function(err) {
console.error(err, err.stack);
callback(err);
});
console.log("2222");
return context.logStreamName
} catch (err) {
console.log(err); …
Run Code Online (Sandbox Code Playgroud)