Co-Requestを使用 して http URL から Zip ファイルを読み取り、サーバーから読み取るコードを以下に示します。
コードはすでに機能しています。しかし、応答 Zip をファイルに書き込む方法がわかりません。
var co = require( "co" );
var request = require( "co-request" );
var options = {
url: "http://www.example.com/sample.zip",
headers: {
'Token': Appconfig.Affiliate_Token,
'Affiliate-Id' : Appconfig.Affiliate_Id
}
}
console.log( "Downloading : zip file" );
var j = yield request( options );
Co-Request は実際には Request のラッパーであり、ファイルをストリームにパイプする以下のコードを見つけました。しかし、Co-Request と yield を使用して同じものを記述する方法がわかりません。
request.get('http://example.com/img.png').pipe(request.put('http://example.com/img.png'))
yield と co-request を使用して応答 zip をファイルに書き込む方法を教えてください