Ruby on rails Bot Microsoft Framework-将附件和存储发送到本地服务器

Ruby on rails Bot Microsoft Framework-将附件和存储发送到本地服务器,ruby-on-rails,node.js,botframework,Ruby On Rails,Node.js,Botframework,我发送了一个附件,它显示我如下: 反应就像- {"body"=>{"type"=>"message", "timestamp"=>"2017-10-31T17:45:37.088Z", "attachments"=>[{"name"=>"bot.png", "contentType"=>"image/png", "contentUrl"=>"http://localhost:45323/v3/attachments/a62ddeiklh5i/views/

我发送了一个附件,它显示我如下:

反应就像-

{"body"=>{"type"=>"message", "timestamp"=>"2017-10-31T17:45:37.088Z", "attachments"=>[{"name"=>"bot.png", "contentType"=>"image/png", "contentUrl"=>"http://localhost:45323/v3/attachments/a62ddeiklh5i/views/original"}],....
我是Node.js和Microsoft Bot Framework的新手

我想将映像存储在本地服务器上。我该怎么做?另外,请提供一些链接,以便我检查并试用。

查看示例。在这里,您将找到使用提供的contentUrl从消息中下载附件的示例代码

之后,您将决定如何在本地服务器上存储

function (session) {

    var msg = session.message;
    if (msg.attachments.length) {

        // Message with attachment, proceed to download it.
        // Skype & MS Teams attachment URLs are secured by a JwtToken, so we need to pass the token from our bot.
        var attachment = msg.attachments[0];
        var fileDownload = checkRequiresToken(msg)
            ? requestWithToken(attachment.contentUrl)
            : request(attachment.contentUrl);

        fileDownload.then(
            function (response) {

                // Send reply with attachment type & size
                var reply = new builder.Message(session)
                    .text('Attachment of %s type and size of %s bytes received.', attachment.contentType, response.length);
                session.send(reply);

            }).catch(function (err) {
                console.log('Error downloading attachment:', { statusCode: err.statusCode, message: err.response.statusMessage });
            });
    }
}

// Helper methods

// Request file with Authentication Header
var requestWithToken = function (url) {
    return obtainToken().then(function (token) {
        return request({
            url: url,
            headers: {
                'Authorization': 'Bearer ' + token,
                'Content-Type': 'application/octet-stream'
            }
        });
    });
};

// Promise for obtaining JWT Token (requested once)
var obtainToken = Promise.promisify(connector.getAccessToken.bind(connector));

var checkRequiresToken = function (message) {
    return message.source === 'skype' || message.source === 'msteams';
};