Programing Language/Node.js
-
Node.js) S3에 업로드한 파일 삭제하기Programing Language/Node.js 2022. 5. 9. 14:45
3에서 이미지나 다른 정적 파일들을 보관하는 경우, 삭제할 필요성이 있다. 선언 const AWS = require('aws-sdk'); let s3 = new AWS.S3(); AWS.config.loadFromPath([AWS config path]) 단일 오브젝트 삭제 s3.deleteObject({ Bucket: 'mybucket', // 사용자 버켓 이름 Key: 'image/helloworld.jpeg' // 버켓 내 경로 }, (err, data) => { if (err) { throw err; } console.log('s3 deleteObject ', data) }) 여러 오브젝트 삭제 var params = { Bucket: "examplebucket", Delete: { Objects..
-
Node.js) mysql에서 Transaction 사용하기 (sql쿼리 성공 여부 확인)Programing Language/Node.js 2021. 12. 29. 10:36
노드에서 mysql 모듈을 사용할 때 트랜잭션 처리하는 방법에 대해서 알아볼게요. 아직 mysql을 연동하지 않았다면 이 글을 먼저 참고해주세요. https://gofnrk.tistory.com/61 Node MySQL 연동 (Express) Node.js에서 MySQL을 연동해볼게요. 연동하고 select, insert, update, delete 쿼리까지 실행시켜 볼거에요. 연동하고 사용하는 것 자체는 매우 간단해요. 우선, mysql2 모듈을 설치해줍니다. npm i mysql2 pool.j.. gofnrk.tistory.com 트랜잭션 예제는 게시글 댓글(board_comment)에 INSERT 하고, 게시글(board)에 댓글 수를 +1 UPDATE 해줄거에요. board와 board_comme..
-
Node.js) Error in results, duplicate field name 해결방법.Programing Language/Node.js 2021. 12. 10. 16:58
에러 메세지를 자세히 보면 (see option `checkDuplicate`) 이라고 나와있다. 메뉴얼을 살펴보자 https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/master/documentation/connection-options.md#other-options GitHub - mariadb-corporation/mariadb-connector-nodejs: MariaDB Connector/Node.js is used to connect applications developed on No MariaDB Connector/Node.js is used to connect applications developed on Node.js..
-
Express) express-session 에서 session 유효 기간 설정하기Programing Language/Node.js 2021. 11. 15. 14:30
앱을 개발하다보면 session의 유효기간을 설정할 필요가 있다. 아래와 같이 설정이 가능하다. var hour = 3600000 req.session.cookie.expires = new Date(Date.now() + hour) req.session.cookie.maxAge = 100 * hour 참고사이트 및 문서 https://stackoverflow.com/questions/46630368/how-to-extend-express-session-timeout http://expressjs.com/en/resources/middleware/session.html 도움 되셨다면 하단의 광고 클릭한번 부탁드립니다~
-
-
-
네아로 로그아웃) service_provider is missing 에러...Programing Language/Node.js 2021. 7. 25. 12:14
레오케빈 2017.10.21. 06:07 https://developers.naver.com/docs/login/devguide/#5-3-1-네아로-연동-해제가-필요한-경우 이 문서 내용대로 수행하면 service_provider is missing. 이라는 에러를 만나게 됩니다. 요청URL 에 service_provider=NAVER 를 추가하면 정상작동합니다. 하지만, 문서에는 이런 내용이 없습니다. 정말 2017년도에 이용자가 제시한 해결방법이 아직도 아직 공식문서에 안내가 없네요...
-
Node.js) 웹에서 svg 파일 읽을때 설정Programing Language/Node.js 2021. 6. 15. 15:07
//기존 png, jpg, jpeg 파일 읽을때 (fs는 모듈) fs.readFile('/home/project/backend/image_files/' + req.params.image/* 파일이름확장자 포함*/, (error, data) => { res.writeHead(200, {'Content-Type': 'image/jpeg'}) res.end(data) // Send the file data to the browser. }); // svg 파일 읽을때 res.writeHead(200, {'Content-Type': 'image/svg+xml'}) //svg+xml 이 부분이 중요