Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const uploadDataPath = `${PATH_UPLOADDATA}/${dataUid}`;
const options = {
hostname,
port : port,
path : `${PATH_UPLOADDATA}/${dataUid}${creds}`,
method : 'POST',
protocol : 'https:',
rejectUnauthorized: false
};
console.log(`uploadData(${dataUid}) : ${options.hostname}:${options.port}${options.path}`);
const stats = fs.statSync(dataPath);
// console.log(stats);
const dataSize = stats['size'];
const dataMD5 = md5File.sync(dataPath);
// console.log('uploadData DATAUID ', dataUid);
// console.log('uploadData DATAMD5SUM ', dataMD5);
// console.log('uploadData DATASIZE ', dataSize);
// console.log('uploadData DATAFILE ', dataPath);
const dataForm = new FormData();
dataForm.append('DATAUID', dataUid);
dataForm.append('DATAMD5SUM', dataMD5);
dataForm.append('DATASIZE', dataSize);
dataForm.append('DATAFILE', fs.createReadStream(dataPath));
dataForm.submit(options, function(err, res) {
if (err) {
reject('uploadData error ' + err);
return;
}
reporter.linkWarning(href, file.path, 'Potentially broken image link detected.');
return href;
}
reporter.brokenLink(href, file.path);
throw new Error('Broken link detected. Stopping build.')
}
// If we're dealing with an asset, give it a name that won't collide, and copy
// it to a central directory.
// TODO(shyndman): This feels out of place here. These methods are about
// rewriting links, not copying assets.
if (patterns.newAssetPathPattern().test(srcLocalUrl.pathname)) {
const destLocalPath = path.join(
CONTENT_ASSETS_PATH,
md5File.sync(srcLocalUrl.pathname) +
path.extname(srcLocalUrl.pathname));
const destAssetHref = path.join(site.siteRoot || '/', destLocalPath);
fs.copySync(srcLocalUrl.pathname, path.join(BuildDir.STAGE, destLocalPath));
return destAssetHref;
}
const pathWithReadme = path.join(srcLocalUrl.pathname, 'README.md');
if (srcPathsToFiles.has(pathWithReadme)) {
srcLocalUrl.pathname = pathWithReadme;
}
// If the specified path has an associated markdown file in the site, rewrite
// the link to point to it, including the search and hash.
if (srcPathsToFiles.has(srcLocalUrl.pathname)) {
const destFile = srcPathsToFiles.get(srcLocalUrl.pathname);
const destLocalUrl = url.parse(
gulp.task('html', () => {
const roslynVersion = getRoslynVersion();
const faviconSvg = fs.readFileSync('favicon.svg', 'utf8');
// http://codepen.io/jakob-e/pen/doMoML
const faviconSvgUrlSafe = faviconSvg
.replace(/"/g, '\'')
.replace(/%/g, '%25')
.replace(/#/g, '%23')
.replace(/{/g, '%7B')
.replace(/}/g, '%7D')
.replace(//g, '%3E')
.replace(/\s+/g,' ');
const jsHash = md5File.sync('wwwroot/app.min.js');
const cssHash = md5File.sync('wwwroot/app.min.css');
return gulp
.src('./index.html')
.pipe(g.htmlReplace({ js: 'app.min.js?' + jsHash, css: 'app.min.css?' + cssHash })) // eslint-disable-line prefer-template
.pipe(g.replace('{build:favicon-svg}', faviconSvgUrlSafe))
.pipe(g.replace('{build:roslyn-version}', roslynVersion))
.pipe(gulp.dest('wwwroot'));
});
function encrypt(passwd) {
let cipher = crypto.createCipher(algor, passwd),
decryptedFileLocation = findFileLocation(DECRYPTED_FILENAME),
decryptedFileFullPath = decryptedFileLocation + DECRYPTED_FILENAME,
encryptedFileFullPath = decryptedFileLocation + ENCRYPTED_FILENAME, // we write encrypted file at same location as where we found decrypted file
encBuff;
if (!passwd) {
throw new Error('encryption requires a password');
}
encBuff = Buffer.concat([cipher.update(readFile(decryptedFileFullPath)), cipher.final()]);
writeFile(encryptedFileFullPath, encBuff);
return md5FileSync(encryptedFileFullPath);
}
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");
module.exports = {
md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/vehiclesimulation/RoutePlanning.pdf")),
name: "RoutePlanning.pdf",
extension: "pdf",
location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/vehiclesimulation/RoutePlanning.pdf"),
metadata: [{
prefix: "nie",
shortName: "plainTextContent",
value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
},
{
prefix: "dcterms",
shortName: "abstract",
value: "This is a pdf file."
},
{
prefix: "dcterms",
shortName: "title",
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");
module.exports = {
md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/SustainableChemistry/doc11.pdf")),
name: "BusPerformance.pdf",
extension: "pdf",
location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/SustainableChemistry/doc11.pdf"),
metadata: [{
prefix: "nie",
shortName: "plainTextContent",
value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
},
{
prefix: "dcterms",
shortName: "abstract",
value: "This is a pdf file."
},
{
prefix: "dcterms",
shortName: "title",
.on('finish', function() {
assert.equal(md5File.sync('data.json'), md5File.sync('test/fixtures/all_docs_include_docs.json'));
fs.unlinkSync('data.json');
mocks.done();
done();
});
}
writeStream.on('close', ()=>{
let md5fname = imageReleasesDir + '.' + fname.replace('.bin', '.md5');
let binfname = imageReleasesDir + fname;
let md5Checksum = md5File.sync(binfname);
fs.writeFileSync(md5fname, md5Checksum);
return resolve(true);
});
entry.pipe(writeStream);
constructor(args = {}, json) {
super(args, json);
if (!json) {
const id = args.id || uuid().toUpperCase();
Object.assign(this, Bitmap.Model, {
do_objectID: id,
name: args.name || id,
frame: new Rect(args.frame),
style: new Style(args.style),
layers: args.layers || [],
});
const fileHash = md5File.sync(args.filePath);
this.image._ref = `images/${fileHash}.png`;
fs.ensureDirSync(STORAGE_IMG_DIR);
fs.copyFileSync(args.filePath, `${STORAGE_DIR}/${this.image._ref}`);
}
return this;
}
}