Skip to content

Commit 7c7cc28

Browse files
authored
Merge pull request #853 from SISheogorath/fix/imgUpload
Fix possible error if HackMD is started with wrong workdir
2 parents 87824d2 + a2608c3 commit 7c7cc28

4 files changed

Lines changed: 4 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ There are some config settings you need to change in the files below.
261261
| `errorPath` | `./public/views/error.ejs` | error template file path |
262262
| `prettyPath` | `./public/views/pretty.ejs` | pretty template file path |
263263
| `slidePath` | `./public/views/slide.hbs` | slide template file path |
264+
| `uploadsPath` | `./public/uploads` | uploads directory - needs to be persistent when you use imageUploadType `filesystem` |
264265
| `sessionName` | `connect.sid` | cookie session name |
265266
| `sessionSecret` | `secret` | cookie session secret |
266267
| `sessionLife` | `14 * 24 * 60 * 60 * 1000` | cookie session life |

lib/config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
errorPath: './public/views/error.ejs',
4646
prettyPath: './public/views/pretty.ejs',
4747
slidePath: './public/views/slide.ejs',
48+
uploadsPath: './public/uploads',
4849
// session
4950
sessionName: 'connect.sid',
5051
sessionSecret: 'secret',

lib/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ config.hackmdPath = path.join(appRootPath, config.hackmdPath)
173173
config.errorPath = path.join(appRootPath, config.errorPath)
174174
config.prettyPath = path.join(appRootPath, config.prettyPath)
175175
config.slidePath = path.join(appRootPath, config.slidePath)
176+
config.uploadsPath = path.join(appRootPath, config.uploadsPath)
176177

177178
// make config readonly
178179
config = deepFreeze(config)

lib/web/imageRouter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ imageRouter.post('/uploadimage', function (req, res) {
1616
form.keepExtensions = true
1717

1818
if (config.imageUploadType === 'filesystem') {
19-
form.uploadDir = 'public/uploads'
19+
form.uploadDir = config.uploadsPath
2020
}
2121

2222
form.parse(req, function (err, fields, files) {

0 commit comments

Comments
 (0)