AWS S3にアップロードしてあるファイルをNode.jsに読み込み、プロジェクトファイル上に複製したいです。
ローカル環境では問題なく動作したのですがHerokuにアップロードした際にデータが途中までしか複製されませんでした。
何か制限などあるのでしょうか?何かわかる方いましたらご教授お願い致します。
また、npmにファイルを読み込めればいいので直接URLから読み込む方法があればそちらも併せてご教授いただきたいです。
よろしくお願いします。
Node.js
1app.get('/gpx_update' , (req, res) => { 2 const file = fs.createWriteStream("file.gpx"); 3 http.get(`fileurl`, response => { 4 response.pipe(file); 5 const fs = require("fs"); 6 7 const stream = fs.createReadStream("./file.gpx", { 8 encoding: "utf8", 9 highWaterMark: 1024 10 }); 11 12 let count = 0; 13 let total = 0; 14 let chunk; 15 global.variable_chunk; 16 17 stream.on("readable", () => { 18 while ( ( chunk = stream.read()) !== null ) { 19 count++; 20 total += chunk.length; 21 console.log(chunk); 22 } 23 }); 24 stream.on("end", () => { 25 //作成したファイルに対する処理 26 } 27 }); 28 }); 29 }); 30 })
追記:読み込もうとしているテキストファイルのサイズは995kbです。
回答1件
あなたの回答
tips
プレビュー