nodejs/docker 환경에서 파일 업로드 이슈 해결
2021. 11. 2. 20:04ㆍ개발/nodejs
docker 사용 후 어느순간 파일 업로드시 nodejs cross-device link not permitted... 오류가 발생하였다.
fs.rename 사용시 발생한 오류였다.
검색 결과 이런저런 방법이 많았지만 가장 간단하게 fs.rename 대신 fs.copyFile 을 사용하여 원하는 경로로 복사하기로 했다.
fs.copyFile 사용
// 기존
/*
fs.rename(old_file, new_file, (err) => {
if(err) console.log(err);
});
*/
// 수정
fs.copyFile(old_file, new_file, (err) => {
// 복사 완료 후 파일 삭제
fs.unlink(old_file, (err) => {});
if (err) console.log(err)
});
'개발 > nodejs' 카테고리의 다른 글
[nodejs] html to image 로 이미지에 글자 및 이미지 넣기 / 한글 깨짐 오류 해결 (0) | 2024.06.26 |
---|---|
[Mac m1] canvas node package 설치 오류 (1) | 2024.06.04 |
[Mac] nvm / node.js 설치 (1) | 2024.06.04 |
nodejs/docker/socket.io(+redis) 여러개의 서버로 채팅 (0) | 2021.11.03 |
nodejs / tensorflow.js 참고 (0) | 2021.10.25 |