Skip to content
Snippets Groups Projects
Commit e7822db4 authored by Дмитрий Малюгин's avatar Дмитрий Малюгин :clock4:
Browse files

fix path win and others for images

parent fa6b4707
No related branches found
No related tags found
1 merge request!4Feature/divider
...@@ -21,7 +21,6 @@ class HomeService { ...@@ -21,7 +21,6 @@ class HomeService {
const blob = await response.blob(); const blob = await response.blob();
const arrayBuffer = await blob.arrayBuffer(); const arrayBuffer = await blob.arrayBuffer();
const buffer = Buffer.from(arrayBuffer); const buffer = Buffer.from(arrayBuffer);
const extension = body.extension.split('/')[1];
const imagePath = path.join(path.resolve(), `/public/images/backgrounds/homeBackground.jpg`); const imagePath = path.join(path.resolve(), `/public/images/backgrounds/homeBackground.jpg`);
fs.writeFileSync(imagePath, buffer); fs.writeFileSync(imagePath, buffer);
...@@ -74,10 +73,19 @@ class HomeService { ...@@ -74,10 +73,19 @@ class HomeService {
async createEntity(body) { async createEntity(body) {
if (body.image_buffer) { if (body.image_buffer) {
const imagePath = path.join(path.resolve(), `/public/images/image.jpg`); const imagePath = path.join(path.resolve(), `/public/images/image.jpg`);
let newImagePath = imagePath.split('/'); let newImagePath;
if (process.platform.includes('win')) {
newImagePath = imagePath.split('\\');
} else {
newImagePath = imagePath.split('/');
}
newImagePath.splice(-1); newImagePath.splice(-1);
newImagePath.push(`${body.entity_uuid}.jpg`); newImagePath.push(`${body.entity_uuid}.jpg`);
newImagePath = newImagePath.join('/'); if (process.platform.includes('win')) {
newImagePath = newImagePath.join('\\');
} else {
newImagePath = newImagePath.join('/');
}
fs.rename(imagePath, newImagePath, function (err) { fs.rename(imagePath, newImagePath, function (err) {
if (err) console.log('ERROR in fs.rename: ' + err); if (err) console.log('ERROR in fs.rename: ' + err);
}); });
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment