Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async handleRequestPut(request, response) {
const directoryPath = normalize(join(String(this.localDirectoryPath), String(request.params.path)));
ensureFileSync(directoryPath);
// strip signature in android , returns same buffer for other clients
var new_data = util.stripChunkSignature(request.body);
// loading data in map for each part
if (request.query.partNumber !== undefined) {
this.upload_bufferMap[request.query.uploadId][request.query.partNumber] = request.body;
} else {
writeFileSync(directoryPath, new_data);
// event trigger to differentitiate between multipart and normal put
let eventObj = this.createEvent(request);
this.emit('event', eventObj);
}
response.send(xml(convert.json2xml(JSON.stringify('upload success'))));
}
item.name = 'img';
item.attributes = {
src: `#file:${item.attributes.hash}`,
alt: file.name,
};
}
else {
item.name = 'a';
item.attributes = {href: `#file:${item.attributes.hash}`};
item.elements = [{type: 'text', text: file.name}];
}
});
/* eslint-enable */
// Convert todo lists
content = convert.json2xml(obj)
.replace(//g, '[] ')
.replace(//g, '[x] ');
// Convert to Markdown
const md = new Turndown();
md.use(gfm);
return md.turndown(content)
.replace(/\n{2,}/g, '\n')
.replace(/\\+\[/g, '[')
.replace(/\\+\]/g, ']');
}
function(error, response) {
if (error === null) {
console.log("serveRequest: response sent:", response);
if(req.query.as_xml) {
res.type('application/xml');
res.send(xmljs.json2xml(
response, {
compact: true,
ignoreComment: true,
spaces: 4
}
));
} else {
res.json(response);
}
} else {
res.status(500);
console.log("serverRequest: error sent: ", error.exception);
res.json(new messages.Error(error.exception.toString(), error.info));
}
}
);
type: "element",
name: "itunes:category",
attributes: {
text: mainCategory,
},
elements: subCategory.length > 0 ? [{
type: "element",
name: "itunes:category",
attributes: {
text: subCategory,
},
}]
:
[],
});
const rssFeed = convert.json2xml(JSON.stringify(jsonFeed), {});
res.set("Content-Type", "text/xml");
res.send(rssFeed);
} catch (e) {
logger.error(e);
return res.sendStatus(404);
}
});
case 'helloWorld':
params = [{
value: [{
string: 'boogy'
}, {
string: 'woogy'
}]
}]
break
}
const methodCall = { methodName, params }
const json = { _declaration, methodCall }
const xml = convert.json2xml(json, { compact: true, spaces: 4 })
const apiUsername = 'dev'
const apiPassword = 'tester'
const encoded = Buffer.from(`${apiUsername}:${apiPassword}`).toString('base64')
const Authorization = `Basic ${encoded}`
const Accept = 'text/xml'
const method = 'POST'
const headers = { Authorization, Accept, 'Content-Type': 'text/xml' }
const body = xml
const fetchTarget = 'http://159.65.111.48:8442'
const fetchOptions = { method, headers, body }
toXml(obj, spaces) {
if (arguments.length < 2) {
spaces = 4;
}
return xmlJS.json2xml(obj, {
compact: false,
spaces: spaces,
});
}
unlink(filePath, err => {
if (err) throw err;
response.send(xml(convert.json2xml(JSON.stringify(request.params.id + 'was deleted'))));
});
} else {