2017-08-24 8 views
0

私はcsvファイルをダウンロードするためのエンドポイントを作成しましたが、ダウンロードする前にエンドポイントを認証する必要があります。つまり、ユーザー名とパスワードを尋ねる必要があります。私はループバックだけでそれをしたいです。どんな助けもありがたい。ありがとう。ループバック認証残りのapi URL

Transaction.csvexport = function(type, res, callback) { 
    res.set('Content-Type','application/download'); 
    res.set('Content-Disposition','attachment;filename=Data.csv'); 
    res.set('Content-Transfer-Encoding','binary'); 
    res.send('ok;'); //@todo: insert CSV data here. 
    }; 
    Transaction.remoteMethod('csvexport', 
    { 
    accepts: [ 
     {arg: 'type', type: 'string', required: true }, 
     {arg: 'res', type: 'object', 'http': {source: 'res'}} 
    ], 
    returns: {}, 
    http: {path: '/csvexport/:type', verb: 'get'} 
    }); 

答えて

0

ダウンロード -

CSVのための私のコード認証は、ループバックでは、デフォルトで有効になっていません。フレームワークを使用してユーザーを作成し、ACLを設定できます。詳細についてはdocumentationをご覧ください。

関連する問題