Added audio upload support to Media API

refs https://github.com/TryGhost/Toolbox/issues/95
refs 4907b7bf1e

- We need support for audio media uploads to be able to used them in cards. The new supported formats are .mp4 and .wav
- Example source files downloaded from https://filesamples.com/
This commit is contained in:
Naz 2021-11-09 16:38:47 +04:00
parent 4721b75463
commit 9edd299905
3 changed files with 16 additions and 2 deletions

View File

@ -31,8 +31,8 @@
"contentTypes": ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/x-icon", "image/vnd.microsoft.icon", "image/webp"]
},
"media": {
"extensions": [".mp4",".webm", ".ogv"],
"contentTypes": ["video/mp4", "video/webm", "video/ogg"]
"extensions": [".mp4",".webm", ".ogv", ".mp3", ".wav"],
"contentTypes": ["video/mp4", "video/webm", "video/ogg", "audio/mpeg", "audio/vnd.wav"]
},
"thumbnails": {
"extensions": [".jpg", ".jpeg", ".gif", ".png", ".svg", ".svgz", ".ico", ".webp"],

View File

@ -74,6 +74,20 @@ describe('Media API', function () {
media.push(res.body.media[0].url.replace(config.get('url'), ''));
});
it('Can upload an mp3', async function () {
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.field('ref', 'audio_file_123')
.attach('file', path.join(__dirname, '/../../utils/fixtures/media/sample.mp3'))
.expect(201);
res.body.media[0].url.should.match(new RegExp(`${config.get('url')}/content/media/\\d+/\\d+/sample.mp3`));
res.body.media[0].ref.should.equal('audio_file_123');
media.push(res.body.media[0].url.replace(config.get('url'), ''));
});
it('Rejects non-media file type', async function () {
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
.set('Origin', config.get('url'))

Binary file not shown.