我正在尝试使用 lambda 将文件从 s3 发送到 azure。但它正在超时并仅上传 15B。
'use strict';
var AWS = require('aws-sdk');
var azure = require('azure-storage');
var s3 = new AWS.S3();
var xml2js = require('xml2js');
var parser = new xml2js.Parser({explicitArray : false});
var extractedData = "";
exports.handler = function(event, context) {
var bucketName = event.Records[0].s3.bucket.name;
var keyName = event.Records[0].s3.object.key;
readFile(bucketName, keyName, readFileContent, onError);
};
function readFile (bucketName, filename, onFileContent, onError) {
var params = { Bucket: bucketName, Key: filename };
s3.getObject(params, function (err, data) {
if (!err)
onFileContent(filename, data.Body);
else
console.log(err);
});
}
function readFileContent(filename, content) {
parser.parseString(content, function(err,result){
console.log(result);
var fileService = azure.createFileService('fgdgdfg','dfgdfgdfgdfgdfg');
fileService.createFileFromText('xfiles', '', 'rros.json', result, function(error, result, response) {
if (!error) {
console.log("file created....")
}else{
console.log(error)
}
});
});
}
function onError (err) {
console.log('error: ' + err);
}
错误:
TypeError:第一个参数必须是 Request.write (/var/task/node_modules/request/request.js:1501:27) 处 ClientRequest.OutgoingMessage.write (_http_outgoing.js:458:11) 的字符串或缓冲区