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

การอ่านค่าตัวต้านทาน Resistor

ตัวต้านทานจะแบงตามประเภทการใช้งานได้สองแบบคือAxial ResistorSMD Resistorวิธีการอ่านค่าก็จะแตกต่างกัน

Structure c/c++

Sructure คือ โครงสร้างข้อมูลที่นําเอาข้อมูลที่มีชนิดข้อมูลต่างกัน แต่มีความสัมพันธิ์ของข้อมูล มาเก็บเข้าไว้ภายในโครงสร้างเดียวกัน ต้วอย่างเช่น การเก็บข้อมูลของพนักงานบริษัทแห่งหนึ่งที่จะต้องเก็บ ชื่อ, นามสกุล, แผนก, และเงินเดือน โดยการเก็บ ชื่อ, นามสกุล, แผนก, และตําแหน่งเป็น String และทําการเก็บเงินเดือนเป็นจํานวนจริง จะเขียนได้ดังนี้

ติดตั้ง และ share printer to raspberry pi or linux computer

สวัสดีครับ ในบทความนี้ผมจะมาแนะนําวิธีการ ติดตั้ง printer ใน raspberry pi หรือ computer ที่มี os เป็น linux ในการจัดการ printer บน linux จะต้องใช้โปรแกรม CUPS เข้ามาช่วย


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

Build with ❤️ and Astro.

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