Skip to content

Commit

Permalink
fix(channel-web): fixed file upload not sending uploaded file namme
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy committed Mar 23, 2019
1 parent d9af389 commit afb5f1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/channel-web/src/backend/api.ts
Expand Up @@ -16,7 +16,10 @@ const ERR_MSG_TYPE = '`type` is required and must be valid'
const ERR_CONV_ID_REQ = '`conversationId` is required and must be valid'

export default async (bp: typeof sdk, db: Database) => {
const globalConfig = (await bp.config.getModuleConfig('channel-web')) as Config

const diskStorage = multer.diskStorage({
destination: globalConfig.fileUploadPath,
limits: {
files: 1,
fileSize: 5242880 // 5MB
Expand All @@ -29,8 +32,6 @@ export default async (bp: typeof sdk, db: Database) => {
}
})

const globalConfig = await bp.config.getModuleConfig('channel-web')

let upload = multer({ storage: diskStorage })

if (globalConfig.uploadsUseS3) {
Expand Down Expand Up @@ -172,8 +173,9 @@ export default async (bp: typeof sdk, db: Database) => {
type: 'file',
data: {
storage: req.file.location ? 's3' : 'local',
url: req.file.location || undefined,
name: req.file.originalname,
url: req.file.location || req.file.path || undefined,
name: req.file.filename,
originalName: req.file.originalname,
mime: req.file.contentType || req.file.mimetype,
size: req.file.size
}
Expand Down
5 changes: 5 additions & 0 deletions modules/channel-web/src/config.ts
Expand Up @@ -35,4 +35,9 @@ export interface Config {
* @default false
*/
showBotInfoPage: boolean
/**
* Destination of file uploads if S3 is not enabled
* @default ./uploads
*/
fileUploadPath: string
}

0 comments on commit afb5f1f

Please sign in to comment.