Skip to content

Commit

Permalink
Merge 01dd0a9 into 86081df
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Nov 9, 2018
2 parents 86081df + 01dd0a9 commit eb1111a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dadi/lib/controller/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ MediaController.prototype.post = function (req, res, next) {

files.push({
data,
fileName: inputFileName,
fileName: inputFileName.replace(/ /g, '_'),
mimeType: inputMimeType
})

Expand Down
25 changes: 25 additions & 0 deletions test/acceptance/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,31 @@ describe('Media', function () {
done(err)
})
})

it('should should replace spaces with underscores in the file name', done => {
client
.post('/media/upload')
.set('Authorization', `Bearer ${bearerToken}`)
.set('content-type', 'application/json')
.attach('file1', 'test/acceptance/temp-workspace/media/a girl on a bridge.jpg')
.end((err, res) => {
if (err) return err

res.body.results.length.should.eql(1)
res.body.results[0].fileName.should.eql('a_girl_on_a_bridge.jpg')
res.body.results[0].path.includes('a_girl_on_a_bridge.jpg').should.eql(true)
res.body.results[0].mimeType.should.eql('image/jpeg')

client
.get(res.body.results[0].path)
.expect(200)
.end((err, res) => {
res.headers['content-type'].should.eql('image/jpeg')

done(err)
})
})
})
})

it('should return 400 if the content type is not `multipart/form-data`', done => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eb1111a

Please sign in to comment.