From 06a9378063b1574efe417175a92ee3df487dd5e6 Mon Sep 17 00:00:00 2001 From: Yuci Gou <yuci.gou@gmail.com> Date: Mon, 4 Mar 2019 17:00:11 +0000 Subject: [PATCH] Clean up minio --- README_MINIO.md | 4 +-- config/default.js | 1 - server/minio-server/README.md | 2 -- .../pubsweet-component-minio/README.md | 5 ++-- server/xpub-model/entities/file/index.js | 27 ------------------- server/xpub-model/test/config/default.js | 1 - 6 files changed, 3 insertions(+), 37 deletions(-) diff --git a/README_MINIO.md b/README_MINIO.md index 07bdc1085..e84231b72 100755 --- a/README_MINIO.md +++ b/README_MINIO.md @@ -20,7 +20,6 @@ MINIO_PORT=9000 MINIO_SECURITY=false MINIO_BUCKET=manuscripts MINIO_UPLOADS_FOLDER_NAME=uploads -MINIO_DATA_FOLDER_NAME=data ``` Configuration 2: @@ -35,7 +34,6 @@ MINIO_PORT=9000 MINIO_SECURITY=false MINIO_BUCKET=manuscripts MINIO_UPLOADS_FOLDER_NAME=uploads -MINIO_DATA_FOLDER_NAME=data ``` In both cases, be sure that the key and secret are the same as those in .env.minio ### 3. REST APIs to use @@ -84,4 +82,4 @@ DELETE: /api/files/{filename} #### List all files ``` GET: /api/files -``` \ No newline at end of file +``` diff --git a/config/default.js b/config/default.js index c38b549dd..959f17f44 100755 --- a/config/default.js +++ b/config/default.js @@ -192,7 +192,6 @@ module.exports = { secure: process.env.MINIO_SECURITY === 'true', bucket: process.env.MINIO_BUCKET, uploads: process.env.MINIO_UPLOADS_FOLDER_NAME, - data: process.env.MINIO_DATA_FOLDER_NAME, }, publicKeys: [ 'pubsweet-client', diff --git a/server/minio-server/README.md b/server/minio-server/README.md index a59ffd703..9916082b6 100755 --- a/server/minio-server/README.md +++ b/server/minio-server/README.md @@ -13,7 +13,6 @@ For example: secure: process.env.MINIO_SECURITY === 'true', bucket: process.env.MINIO_BUCKET, uploads: process.env.MINIO_UPLOADS_FOLDER_NAME, - data: process.env.MINIO_DATA_FOLDER_NAME, }, ``` @@ -27,7 +26,6 @@ MINIO_PORT=9000 MINIO_SECURITY=true MINIO_BUCKET=manuscripts MINIO_UPLOADS_FOLDER_NAME=uploads -MINIO_DATA_FOLDER_NAME=data ``` Then, as soon as possible in your app you should add the `dotenv` package: diff --git a/server/modules/pubsweet-component-minio/README.md b/server/modules/pubsweet-component-minio/README.md index 3ba16aa6e..34d53ee11 100755 --- a/server/modules/pubsweet-component-minio/README.md +++ b/server/modules/pubsweet-component-minio/README.md @@ -24,7 +24,6 @@ MINIO_PORT=9000 MINIO_SECURITY=false MINIO_BUCKET=manuscripts MINIO_UPLOADS_FOLDER_NAME=uploads -MINIO_DATA_FOLDER_NAME=data ``` ## Then you can use the Minio middleware in your Express application: @@ -57,7 +56,7 @@ app.post('/api/files', minioMiddleware({op: minioClient.Ops.post}), (req, res) = }) app.get('/api/files', - minioMiddleware({op: minioClient.Ops.list}), + minioMiddleware({op: minioClient.Ops.list}), (req, res) => { if (req.minio.error) { res.status(400).json({ error: req.minio.error }) @@ -85,4 +84,4 @@ app.delete('/api/files/:filename', res.send(req.minio.delete); } ) -``` \ No newline at end of file +``` diff --git a/server/xpub-model/entities/file/index.js b/server/xpub-model/entities/file/index.js index 4ee2a7e62..06716fbec 100644 --- a/server/xpub-model/entities/file/index.js +++ b/server/xpub-model/entities/file/index.js @@ -1,11 +1,8 @@ const lodash = require('lodash') -const rfr = require('rfr') const FileAccess = require('./data-access') // const dataAccess = new FileAccess() -const { minioClient } = rfr('server/modules/pubsweet-component-minio') - const empty = { filename: '', label: '', @@ -35,31 +32,7 @@ const FileManager = { return { ...file, id } }, - putContent: async (file, content, { size } = {}) => { - if (!file.id) { - throw new Error('File has no ID, must be saved first') - } - const data = process.env.MINIO_DATA_FOLDER_NAME - const metaData = { - 'Content-Type': file.mimetype, - 'Content-Length': size, - } - return minioClient.putObject( - process.env.MINIO_BUCKET, - `${data}/${file.url}/${file.id}`, - content, - metaData, - ) - }, - getContent: async file => { - const data = process.env.MINIO_DATA_FOLDER_NAME - const Body = await minioClient.getObject( - process.env.MINIO_BUCKET, - `${data}/${file.url}/${file.id}`, - ) - return Body - }, modelName: 'File', model: FileAccess, diff --git a/server/xpub-model/test/config/default.js b/server/xpub-model/test/config/default.js index af8723878..93297140c 100755 --- a/server/xpub-model/test/config/default.js +++ b/server/xpub-model/test/config/default.js @@ -162,7 +162,6 @@ module.exports = { secure: process.env.MINIO_SECURITY === 'true', bucket: process.env.MINIO_BUCKET, uploads: process.env.MINIO_UPLOADS_FOLDER_NAME, - data: process.env.MINIO_DATA_FOLDER_NAME, }, publicKeys: ['pubsweet-client', 'authsome', 'validations'], elife: { -- GitLab