mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
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:
parent
4721b75463
commit
9edd299905
@ -31,8 +31,8 @@
|
|||||||
"contentTypes": ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/x-icon", "image/vnd.microsoft.icon", "image/webp"]
|
"contentTypes": ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/x-icon", "image/vnd.microsoft.icon", "image/webp"]
|
||||||
},
|
},
|
||||||
"media": {
|
"media": {
|
||||||
"extensions": [".mp4",".webm", ".ogv"],
|
"extensions": [".mp4",".webm", ".ogv", ".mp3", ".wav"],
|
||||||
"contentTypes": ["video/mp4", "video/webm", "video/ogg"]
|
"contentTypes": ["video/mp4", "video/webm", "video/ogg", "audio/mpeg", "audio/vnd.wav"]
|
||||||
},
|
},
|
||||||
"thumbnails": {
|
"thumbnails": {
|
||||||
"extensions": [".jpg", ".jpeg", ".gif", ".png", ".svg", ".svgz", ".ico", ".webp"],
|
"extensions": [".jpg", ".jpeg", ".gif", ".png", ".svg", ".svgz", ".ico", ".webp"],
|
||||||
|
@ -74,6 +74,20 @@ describe('Media API', function () {
|
|||||||
media.push(res.body.media[0].url.replace(config.get('url'), ''));
|
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 () {
|
it('Rejects non-media file type', async function () {
|
||||||
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
|
const res = await request.post(localUtils.API.getApiQuery('media/upload'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
BIN
test/utils/fixtures/media/sample.mp3
Normal file
BIN
test/utils/fixtures/media/sample.mp3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user