Skip to content

Commit

Permalink
fix: upload image in the right directory
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Jan 13, 2017
1 parent d90db34 commit 751e351
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/cli/cms/media/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ export function saveFile(req) {

var folderFilePath = createMediaFolder(mediaType)
var hasSentHeader = false
var folderWebPath = '/' + config.upload.image
if(config.upload[mediaType] != null){
folderWebPath = '/' + config.upload[mediaType]
}

filePath = path.join(folderFilePath, slug)
resp['filePath'] = path.join('/' + mediaType, slug)
resp['filePath'] = path.join('/' + folderWebPath, slug)

file.on('limit', function() {
hasSentHeader = true
Expand Down Expand Up @@ -177,7 +181,10 @@ export function createMediaSlug(filename, ext) {
}

export function createMediaFolder(mediaType) {
var folderWebPath = '/' + mediaType
var folderWebPath = '/' + config.upload.image
if(config.upload[mediaType] != null){
folderWebPath = '/' + config.upload[mediaType]
}
folderWebPath = abeExtend.hooks.instance.trigger('beforeSaveImage', folderWebPath)
var folderFilePath = path.join(config.root, config.publish.url, folderWebPath)
mkdirp.sync(folderFilePath)
Expand Down
2 changes: 1 addition & 1 deletion src/cli/core/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"image": "image",
"video": "video",
"document": "document",
"document": "sound",
"sound": "sound",
"fileSizelimit": 10485760,
"extensions":[".gif", ".jpg", ".jpeg", ".png", ".svg", ".mp4"],
"mimetypes": ["image/gif", "image/jpeg", "image/png", "image/svg+xml", "video/mp4"]
Expand Down

0 comments on commit 751e351

Please sign in to comment.