fixed fs.renameSync & docker issue
This commit is contained in:
parent
155faa6731
commit
47e90764e7
|
@ -3,9 +3,12 @@ services:
|
||||||
build: .
|
build: .
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- 8012:3000
|
- 8012:8080
|
||||||
depends_on:
|
depends_on:
|
||||||
- database
|
- database
|
||||||
|
volumes:
|
||||||
|
- ./data/temp:/temp
|
||||||
|
- ./data/uploads:/uploads
|
||||||
database:
|
database:
|
||||||
image: 'postgres:15'
|
image: 'postgres:15'
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@ class AbstractProductController {
|
||||||
return res.status(400).send("Only .png files are allowed")
|
return res.status(400).send("Only .png files are allowed")
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.renameSync(tempPath, targetPath);
|
//fs.renameSync(tempPath, targetPath);
|
||||||
|
fs.copyFileSync(tempPath, targetPath);
|
||||||
|
fs.rmSync(tempPath);
|
||||||
await AbstractProductService.create(groupId, localId, barcode, name, net_weight, image_filename, category, unit);
|
await AbstractProductService.create(groupId, localId, barcode, name, net_weight, image_filename, category, unit);
|
||||||
return res.status(200).send("Successfull");
|
return res.status(200).send("Successfull");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -48,7 +49,9 @@ class AbstractProductController {
|
||||||
if (net_weight) await AbstractProductService.updateNetWeight(groupId, localId, net_weight);
|
if (net_weight) await AbstractProductService.updateNetWeight(groupId, localId, net_weight);
|
||||||
|
|
||||||
if (image_filename && tempPath) {
|
if (image_filename && tempPath) {
|
||||||
fs.renameSync(tempPath, targetPath);
|
//fs.renameSync(tempPath, targetPath);
|
||||||
|
fs.copyFileSync(tempPath, targetPath);
|
||||||
|
fs.rmSync(tempPath);
|
||||||
await AbstractProductService.updateImageFilename(groupId, localId, image_filename);
|
await AbstractProductService.updateImageFilename(groupId, localId, image_filename);
|
||||||
} else if (image_filename && !tempPath) {
|
} else if (image_filename && !tempPath) {
|
||||||
return res.status(400).send("You must supply image file along with its hash");
|
return res.status(400).send("You must supply image file along with its hash");
|
||||||
|
@ -74,4 +77,4 @@ class AbstractProductController {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default new AbstractProductController();
|
export default new AbstractProductController();
|
||||||
|
|
Loading…
Reference in New Issue