Skip to content

🔥 The free & Open Source DocuSign alternative

#146 - Fix issue of build & Add local File upload support

rishabjasrotiadbff436bc25a
diff --git a/.gitignore b/.gitignore
index 8e62b9ce7..b6dcebdf3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,4 +23,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
apps/OpenSign/public/mfbuild/*
-microfrontends/SignDocuments/build/*
\ No newline at end of file
+microfrontends/SignDocuments/build/*
+apps/OpenSignServer/files/files/*
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 35fa55901..7cf392883 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,9 @@
build:
+ cp .env.local_dev .env
+ rm -rf apps/OpenSign/public/mfbuild
+ cd microfrontends/SignDocuments && npm install && npm run build
+ docker compose up -d
+
+run:
cp .env.local_dev .env
docker compose up -d
\ No newline at end of file
diff --git a/apps/OpenSign/Dockerfile b/apps/OpenSign/Dockerfile
index 7d8542bf6..57c815846 100644
--- a/apps/OpenSign/Dockerfile
+++ b/apps/OpenSign/Dockerfile
@@ -21,5 +21,5 @@ EXPOSE 3000
# ENV NODE_ENV production
# Run the application
-CMD ["npm", "start"]
+ENTRYPOINT npm run start-dev
diff --git a/apps/OpenSign/public/mfbuild/.gitkeep b/apps/OpenSign/public/mfbuild/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/apps/OpenSignServer/cloud/customRoute/uploadFile.js b/apps/OpenSignServer/cloud/customRoute/uploadFile.js
index 34abc14d0..6a87c386d 100644
--- a/apps/OpenSignServer/cloud/customRoute/uploadFile.js
+++ b/apps/OpenSignServer/cloud/customRoute/uploadFile.js
@@ -50,16 +50,28 @@ async function uploadFile(req, res) {
region: process.env.DO_REGION,
});
- // const s3 = new aws.S3();
- const upload = multer({
- fileFilter: function (req, file, cb) {
- if (accepted_extensions.some(ext => file.originalname.toLowerCase().endsWith('.' + ext))) {
- return cb(null, true);
+ const parseBaseUrl = process.env.REACT_APP_SERVERURL;
+ const parseAppId = process.env.APP_ID;
+
+ if (process.env.USE_LOCAL == "TRUE") {
+ var fileStorage = multer.diskStorage({
+ destination: function(req, file, cb) {
+ cb(null, "files/files");
+ },
+ metadata: function (req, file, cb) {
+ cb(null, { fieldName: 'OPENSIGN_METADATA' });
+ },
+ filename: function(req, file, cb) {
+ let filename = file.originalname;
+ let filenam = filename.split('.')[0];
+ let extension = filename.split('.')[1];
+ filenam = filenam + '_' + new Date().toISOString() + '.' + extension;
+ console.log(filenam);
+ cb(null, filenam);
}
- // otherwise, return error
- return cb('Only ' + accepted_extensions.join(', ') + ' files are allowed!');
- },
- storage: multerS3({
+ });
+ } else {
+ var fileStorage = multerS3({
acl: 'public-read',
s3,
bucket: DO_SPACE,
@@ -74,9 +86,20 @@ async function uploadFile(req, res) {
filenam = filenam + '_' + new Date().toISOString() + '.' + extension;
console.log(filenam);
cb(null, filenam);
- },
- }),
+ }
+ });
+ }
+ // const s3 = new aws.S3();
+ const upload = multer({
+ fileFilter: function (req, file, cb) {
+ if (accepted_extensions.some(ext => file.originalname.toLowerCase().endsWith('.' + ext))) {
+ return cb(null, true);
+ }
+ // otherwise, return error
+ return cb('Only ' + accepted_extensions.join(', ') + ' files are allowed!');
+ },
+ storage: fileStorage,
limits: { fileSize: size },
}).single('file');
@@ -93,7 +116,14 @@ async function uploadFile(req, res) {
const status = 'Success';
//res.header("Access-Control-Allow-Headers", "Content-Type");
//res.setHeader("Access-Control-Allow-Origin", "*");
- return res.json({ status, imageUrl: req.file.location });
+ if (process.env.USE_LOCAL == "TRUE") {
+ console.log(req.file);
+ var fileUrl = `${parseBaseUrl}/files/${parseAppId}/${req.file.filename}`;
+ } else {
+ var fileUrl = req.file.location;
+ }
+
+ return res.json({ status, imageUrl: fileUrl });
});
} catch (err) {
console.log('Exeption in query ' + err.stack);