Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const postRouter = require('./routes/board.js');
const likeRouter = require('./routes/like.js');

dotenv.config();
app.use(express.urlencoded({extended : true}));
app.use(bodyParser.json());
app.use(express.urlencoded({limit: '100mb', extended : true}));
app.use(bodyParser.json({limit: '100mb'}));
app.use('/public', express.static('public'));

/* 안드로이드와 HTTP 통신 */
Expand Down
8 changes: 8 additions & 0 deletions Server/services/boardSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ module.exports = {
const base64Image = Buffer.from(postData.image_data, 'base64');
const savePath = path.join(__dirname, '..', 'public', 'images', postData.image_name);

// public/images 디렉토리에 접근 가능한지 판단 (해당 디렉토리가 있는지)
try {
await fs.access(path.join(__dirname, 'public', 'images'))
} catch (error) {
console.log(error.message);
await fs.mkdir(path.join(__dirname, 'public', 'images'), {recursive : true}); // 디렉토리 없으면 생성
}

// 디코딩한 이미지 저장
await fs.writeFile(savePath, base64Image);
console.log('Save Complete : ' + savePath);
Expand Down