nodejs - 브 라 우 저 에서 기본적으로 열 린 파일 을 다운로드 로 변환 합 니 다.
731 단어 nodejs
var express=require("express")
var app=express();
var fs = require('fs');
var path=require("path");
app.get("/upload",function(req,res){
var filePath = path.join(__dirname, './');
console.log(filePath)
fs.readFile(filePath+"images/2010191.png", function(err, data){
res.set({
'Content-Type': 'application/octet-stream', //
'Content-Disposition': 'attachment; filename=upload.png' // png
});
res.end(data)
})
})
app.listen(3000,function(){
console.log("server is running")
})
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Node.js를 AWS서버에서 사용하는 실습간단한 예제와 함께 AWS에서 Node.js를사용하는 법을 배워보도록 하겠다. 해당 github에 있는 레포지토리로 사용을 할 것이다. 3000번 포트로 Listen되는 예제이고 간단히 GET, POST, DELET...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.