Skip to content

Commit

Permalink
fix(users): debug user picture api / bind public folder to volume
Browse files Browse the repository at this point in the history
  • Loading branch information
MengChiehLiu committed Aug 21, 2023
1 parent 85575cd commit 32ca555
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
public
private
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
restart: always
volumes:
- balanceCat_server_volume:/shared_data/server
- ./public:/BalanceCat/public
ports:
- "3000:3000"
networks:
Expand Down
5 changes: 2 additions & 3 deletions server/controllers/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const upload = multer({ storage: storage });

async function usersPictureUpdate(req, res) {
try {
const userId = req.headers.authorization;
const userId = req.user.id;

await new Promise((resolve, reject) => {
// 執行圖片上傳
Expand All @@ -105,11 +105,10 @@ async function usersPictureUpdate(req, res) {
});
});

const picturePath = req.file.path.replace('public/', '');
const protocol = req.protocol; // 通常是 'http' 或 'https'
const host = '54.236.231.127'; // 獲取主機名,例如 '127.0.0.1:3000'
const serverUrl = `${protocol}://${host}`;
const pictureUrl = `${serverUrl}/api/1.0/images/${path.basename(picturePath)}`;
const pictureUrl = `${serverUrl}/api/1.0/images/${path.basename(req.file.path)}`;

await updateUserPicture(userId, pictureUrl);

Expand Down

0 comments on commit 32ca555

Please sign in to comment.