1
にAWSラムダにfs.writeFileで.txtファイルを作成し、読み方、こんにちは
誰かが私はAWSラムダに.TXTを書くことができる方法を知っていますか? Node.js、Alexa Skills Kit、Lambdaを使用しています。
マイコード:
var fs = require('fs');
const handlers = {
'SetOrderIntent': function() {
if (this.event.request.intent) {
var test = this.event.request.intent.slots.Items.value;
fs.writeFile('/tmp/log.txt', test, function (err) {
if (err) throw err;
});
this.emit(':ask', 'This is your item: ' + test, "Test");
}
},
'RetrieveOrderIntent': function() {
if (this.event.request.intent) {
fs.readFile('/tmp/log.txt', function (err, content) {
if (err) return callback(err)
callback(null, content)
})
this.emit(':ask', content);
}
},
}
S3を使用したり、session.Attributesを使用することをお勧めしますか? – Mae
私はそれがあなたのデータのサイズに依存すると思うが、私にとってはそれは唯一の文字列のように見える? session.Attributesを試す必要があります。 また、あなたは 'RetrieveOrderIntent'で同期を出しています。これは、readFileがコールバックで実際に終了する前に、あなたのemitが起動されたことを意味します。 readFileコールバックの中で 'this.emit'を動かすべきです。 'callback'はどこから来たのでしょうか? – driedel
@Maeはうまくいった? – driedel