NodeJ:Exiftool出现错误无法排队任务-charset 并且 BatchCluster已结束在AWS Lambda环境中。得到以下错误:
无法排队任务错误:
filename=utf8
-codedcharacterset=utf8
-sep
-E
-all=
/tmp/5dd3ea51b1fc4010107250.jpg
-ignoreMinorErrors
-execute
at BatchCluster.enqueueTask (/var/task/node_modules/batch-cluster/dist/BatchCluster.js:226:19)
at /var/task/node_modules/exiftool-vendored/dist/ExifTool.js:317:83
at Object.<anonymous> (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:48:42)
at step (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:33:23)
at Object.next (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:14:53)
at /var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:4:12)
at g (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:42:34)
at Object.<anonymous> (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:54:47)
BatchCluster已结束错误:
UnhandledPromiseRejectionWarning: Error: BatchCluster has ended
at BatchCluster.enqueueTask (/var/task/node_modules/batch-cluster/dist/BatchCluster.js:225:25)
at /var/task/node_modules/exiftool-vendored/dist/ExifTool.js:317:83
at Object.<anonymous> (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:48:42)
at step (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:33:23)
at Object.next (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:14:53)
at /var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:4:12)
at g (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:42:34)
at Object.retryOnReject (/var/task/node_modules/exiftool-vendored/dist/AsyncRetry.js:64:12)
一个功能与系统正常工作的系统可以第一次调用lambda函数,而另一个时候称为lambda函数函数却会出错,AWS Lamda。我已经使用了此软件包https://www.npmjs.com/package/exiftool-vendored。
我的PHP函数:
$filename = 'filename1.jpg';
$keywords = "TEST KEYWORDS";
$filename_values = ['original'=>$filename,'thumb'=>$filename,'medium'=>$filename];
//var_dump($array);
foreach ($filename_values as $key => $value) {
$files_array = ['files'=>[$key=>$value],'metadata'=>$keywords];
$files_array = json_encode($files_array);
$result = $client->invoke([
// The name your created Lamda function
'FunctionName' => 'lambda function',
'Payload' => $files_array
// 'Payload' => '{"files":{"original": "'.$filename.'","thumb":"'.$filename.'","medium":"'.$filename.'"},"metadata":"'.$keywords.'"}'
]);
echo $result['Payload'];
}
我的nodejs函数:
exports.handler = function index(event, context, callback) {
for(var attributename in event.files){
//console.log(event.files[attributename]);
const exiftool = require("exiftool-vendored").exiftool;
console.log(exiftool);
downloadS3(exiftool,event.files[attributename],metadata,attributename);
}
}
function downloadS3(exiftool,filename,metadata,attributename) {
var s3 = new AWS.S3();
var file = fs.createWriteStream('/tmp/'+filename);
file.on('close', function(){
console.log("done1");
exiftool
.deleteAllTags('/tmp/'+filename)
.then(() => exiftool.write('/tmp/'+filename, { Keywords: metadata }))
.catch(err => console.error(err))
.then(()=>uploadToS3(filename,attributename))
.then(() => exiftool.end())
});
s3.getObject("s3 details").createReadStream().on('error', function(err){
console.log("here");
}).pipe(file);
}
请帮助我解决此问题。
谢谢。