mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Fix upload API in regards to url-encoding the audio stream
This commit is contained in:
parent
d9f3835f96
commit
407627ef6a
|
|
@ -10,7 +10,7 @@ if (Meteor.isServer) {
|
||||||
if (req.method === 'POST') {
|
if (req.method === 'POST') {
|
||||||
const form = new Form();
|
const form = new Form();
|
||||||
|
|
||||||
let audio = 'data:audio/mpeg;base64,';
|
let audio = '';
|
||||||
let json = '';
|
let json = '';
|
||||||
let key = '';
|
let key = '';
|
||||||
let system = '';
|
let system = '';
|
||||||
|
|
@ -19,10 +19,10 @@ if (Meteor.isServer) {
|
||||||
part.on('data', (data) => {
|
part.on('data', (data) => {
|
||||||
switch (part.name.toLowerCase()) {
|
switch (part.name.toLowerCase()) {
|
||||||
case 'audio':
|
case 'audio':
|
||||||
audio += data.toString('base64');
|
audio += data.toString('binary');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
json += data.toString('binary');
|
json += data.toString('utf8');
|
||||||
break;
|
break;
|
||||||
case 'key':
|
case 'key':
|
||||||
key += data.toString('utf8');
|
key += data.toString('utf8');
|
||||||
|
|
@ -40,6 +40,8 @@ if (Meteor.isServer) {
|
||||||
const apiKeys = Meteor.settings.apiKeys;
|
const apiKeys = Meteor.settings.apiKeys;
|
||||||
|
|
||||||
if (key && Array.isArray(apiKeys) && apiKeys.find((apiKey) => apiKey === key)) {
|
if (key && Array.isArray(apiKeys) && apiKeys.find((apiKey) => apiKey === key)) {
|
||||||
|
audio = 'data:audio/mpeg;base64,' + Buffer.from(audio, 'binary').toString('base64');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const call = new Call(Object.assign({}, JSON.parse(json), { audio, system }));
|
const call = new Call(Object.assign({}, JSON.parse(json), { audio, system }));
|
||||||
|
|
||||||
|
|
@ -57,7 +59,6 @@ if (Meteor.isServer) {
|
||||||
res.writeHead(403);
|
res.writeHead(403);
|
||||||
res.end('wrong or no api key provided');
|
res.end('wrong or no api key provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
form.parse(req);
|
form.parse(req);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue