fix: replace spaces in upload filenames

This commit is contained in:
Nick 2019-06-02 22:18:11 -04:00
parent b38655b91c
commit a50bb2f281
3 changed files with 6 additions and 4 deletions

View File

@ -10,9 +10,9 @@
.body-2(:class='$vuetify.dark ? `white--text` : `teal--text`') Assets
v-spacer
v-btn(flat, icon, @click='refresh')
v-icon cached
v-icon(:color='$vuetify.dark ? `white` : `teal`') refresh
v-dialog(v-model='newFolderDialog', max-width='550')
v-btn.my-0.mr-0.radius-7(outline, large, color='teal', :icon='$vuetify.breakpoint.xsOnly', slot='activator')
v-btn.ml-3.my-0.mr-0.radius-7(outline, large, color='teal', :icon='$vuetify.breakpoint.xsOnly', slot='activator')
v-icon(:left='$vuetify.breakpoint.mdAndUp') add
span.hidden-sm-and-down(:class='$vuetify.dark ? `teal--text text--lighten-3` : ``') New Folder
v-card.wiki-form

View File

@ -73,6 +73,9 @@ router.post('/u', multer({
}
}
// Sanitize filename
fileMeta.originalname = sanitize(fileMeta.originalname.toLowerCase().replace(/[\s,;]+/g, '_'))
// Check if user can upload at path
const assetPath = (folderId) ? hierarchy.map(h => h.slug).join('/') + `/${fileMeta.originalname}` : fileMeta.originalname
if (!WIKI.auth.checkAccess(req.user, ['write:assets'], { path: assetPath })) {
@ -85,7 +88,6 @@ router.post('/u', multer({
// Process upload file
await WIKI.models.assets.upload({
...fileMeta,
originalname: sanitize(fileMeta.originalname).toLowerCase(),
folderId: folderId,
assetPath,
userId: req.user.id

View File

@ -42,7 +42,7 @@ module.exports = {
try {
const folderSlug = sanitize(args.slug).toLowerCase()
const parentFolderId = args.parentFolderId === 0 ? null : args.parentFolderId
const result = await WIKI.models.assetFolders.query().where({
const result = await WIKI.models.assetFolders.query().where({
parentId: parentFolderId,
slug: folderSlug
}).first()