How to send a file from remote URL in Node.js Express app

23 Mar 2018,
Share: 

ใน nodejs express ถ้าต้องการ Response file จาก url อื่นๆ ตัวอย่างเช่น เรามี url “https://www.mydomain1.com/bg” แต่เราต้องการให้ เมื่อ Client เรียก url ดังกล่าวแล้ว ให้ไปนําข้อมูลจาก url “https://www.mydomain2.com/bg.jpg” ตอบกับไปให้ Client เราสามารทําได้ตามตัวอย่างดังนี้ครับ

var request = require('request');
var express = require('express');
var app = express();

app.get('/', function (req, res) {
    request('https://firebasestorage.googleapis.com/v0/b/uppic-190010.appspot.com/o/1_4Sq2I0T30xUmdywMzb60WQ.png?alt=media&token=c8412d21-dbd4-4acd-82c4-47b171fe4f18').pipe(res);
});

app.listen(3000);

จากตัวอย่าง เรากําหนดให้ เมื่อ Client เรียกมาที่ path ”/” จะไปเอาข้อมูลจาก url “https://firebasestorage.googleapis.com/v0/b/uppic-190010.appspot.com/o/1\_4Sq2I0T30xUmdywMzb60WQ.png?alt=media&token=c8412d21-dbd4-4acd-82c4-47b171fe4f18” มาตอบกลับไปให้ Client

Suggestion blogs

เหรียญ 10 บาท ๑๐๐ ปี กรมศิลปากร พ.ศ.๒๕๕๔

เหรียญ 10 บาท ๑๐๐ ปี กรมศิลปากร พ.ศ.2554 กระทรวงการคลังได้จัดทำเหรียญกษาปณ์ที่ระลึกเนื่องในโอกาสครบ ๑๐๐ ปี กรมศิลปากร ในวันที่ ๒๗ มีนาคม พ.ศ. ๒๕๕๔

การอ่านค่าความจุของตัวเก็บประจุ Capacitor

ปัจจุบันตัวเก็บประจุถูกผลิตออกมามากมายหลายแบบ ประเภทของตัวเก็บประจุที่พบส่วนใหญ่มีดังนี้Tantalum electrolytic capacitorsCeramic capacitorsSilver mica capacitorsMylar capacitorsBipolar capacitorsElectrolytic capacitors

Scanline Flood fill Algorithm

Flood fill AlgorithmFlood fill Algorithm คือ Algorithm การระบายสีโดยมีเงื่อนไขอยู่ว่ารูปทรงที่ต้องการระบายนั้นจะต้องเป็นรูปปิด ถ้าใครนึกภาพไม่ออกก็ลองนึกถึงโปรแกรม paint จะมีเครื่องมือเทสี(Fill) มีลักษณะเช่นเดียวกัน


Copyright © 2019 - 2025 thiti.dev |  v1.53.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ