How to use the download function in download

To help you get started, we’ve selected a few download examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github itsezc / CycloneIO / packages / utils / clothing / source / extractor.ts View on Github external
async init() {
        Logger.info(`${magenta('[DOWNLOADING]')} Figure Map`)

        const url = `${flashImagesURL}/gordon/${PRODUCTION}/figuremap.xml`
        const figureMap = await Download(url, undefined, { encoding: 'utf8' })

        Logger.info(`${magenta('[DOWNLOADING]')}${green('[DONE]')} Figure Map`)

        const swfs = await this.parser.parseFigureMap(figureMap)

        if (swfs.length > 0) {
            const data = await this.extractSWFs(swfs)

            await Promise.all(data.map(async data => {
                const { name } = data

                Logger.info(`${cyanBright('[GENERATING]')}${red('[IMAGES]')} ${name}`)

                const { metaData, paths } = await this.generator.generateImages(data)

                Logger.info(`${cyanBright('[GENERATING]')}${magentaBright('[METADATA]')} ${name}`)
github itsezc / CycloneIO / source / utils / swf / index.js View on Github external
const furni = furnis[furniId];

		console.log(chalk`{blue [Downloading]} ${furni.name} (${furni.classname})`);

		try {
			await downloadFurni(furni);
		} catch (err) {
			console.log(chalk`{red [ERROR]} ${furni.name} (${furni.classname}) ${buildFurniUrl(furni.revision, furni.classname)}`);
		}

		writeFurni(furni);
		console.log(chalk`{green [Done]} ${furni.name} (${furni.classname})`);
	}
}

Download(Config.furniDataURL, path.join(__dirname, 'raw')).then(() => {
	const xml = fs.readFileSync(path.join(__dirname, 'raw', 'furnidata.xml'));

	const {roomitemtypes, wallitemtypes} = Parser.parse(xml.toString(), {
		attributeNamePrefix : '',
		ignoreAttributes: false,
		parseAttributeValue: true
	}).furnidata;

	downloadSWFs(roomitemtypes.furnitype.filter(furni => !furni.classname.includes('*')));
	downloadSWFs(wallitemtypes.furnitype);
});
github itsezc / CycloneIO / source / server / utils / swf / furniture.ts View on Github external
async download(): Promise {

		try {

			var URLPath = downloadURL.concat(this.revision, '/', this.className, '.swf')

			await Download(URLPath).then(data => {

				this.extract(data)

			})

		}

		catch(error) {
			Logger.error(error)
		}
	}
github itsezc / CycloneIO / source / utils / swf / furniture.ts View on Github external
private download(): void
	{
		try 
		{
			var destination = Path.join(__dirname, 'out', this.className)
			var filePath = Path.join(destination, this.className.concat('.swf'))
			var URLPath = downloadURL.concat(this.revision.toString(), '/', this.className, '.swf')

			var exists = IO.existsSync(filePath)

			if (!exists)
			{
				IO.mkdirSync(destination, { recursive: true })

				Download(URLPath).then(data => 
				{
					IO.writeFileSync(filePath, data)

				}).catch(error => {
					throw error
				})
			}
		}

		catch(error) 
		{
			Logger.error(error)
		}
	}
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / installResolver / utils / downloadInstallationFiles.js View on Github external
export default async () => {
    if (downloaded) {
        return INSTALL_EXTRACT_DIR;
    }

    const s3 = new S3({ region: process.env.AWS_REGION });
    const installationFilesUrl = await s3.getSignedUrlPromise("getObject", {
        Bucket: PAGE_BUILDER_S3_BUCKET,
        Key: PAGE_BUILDER_INSTALLATION_FILES_ZIP_KEY
    });

    fs.ensureDirSync(INSTALL_DIR);
    fs.writeFileSync(INSTALL_ZIP_PATH, await download(installationFilesUrl));

    await extractZip(INSTALL_ZIP_PATH, INSTALL_DIR);
    await deleteFile(INSTALL_ZIP_PATH);

    return INSTALL_EXTRACT_DIR;
};
github itsezc / CycloneIO / source / server / utils / swf / furnidata.ts View on Github external
public async download(): Promise {

		try {

			await Download(furnidataURL, { encoding: 'utf8' }).then((data) => {
				this.parse(data)
			})

		}

		catch(error) {
			Logger.error(error)
		}
	}
github motivast / motimize / src / web / middlewares / handlers / image.js View on Github external
async function handleUrl(fileUrl) {
  let tmp = tempfile();

  let parsed = url.parse(fileUrl);
  let filename = path.basename(parsed.pathname);

  let downloaded = await download(fileUrl);

  fs.writeFileSync(tmp, downloaded);

  checkMimeType(tmp);

  return { filename: filename, path: tmp };
}
github Hitachi-Automotive-And-Industry-Lab / semantic-segmentation-editor / server / config.js View on Github external
const init = ()=> {
    try {
        const config = Meteor.settings;

        if (config.configuration && config.configuration["images-folder"] != "") {
            configurationFile.imagesFolder = config.configuration["images-folder"].replace(/\/$/, "");
        }else{
            configurationFile.imagesFolder = join(os.homedir(), "sse-images");
        }

        if (!existsSync(configurationFile.imagesFolder)){
            mkdirSync(configurationFile.imagesFolder);
            download("https://raw.githubusercontent.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor/master/private/samples/bitmap_labeling.png", configurationFile.imagesFolder);
            download("https://raw.githubusercontent.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor/master/private/samples/pointcloud_labeling.pcd", configurationFile.imagesFolder);
        }

        if (config.configuration && config.configuration["internal-folder"] != "") {
            configurationFile.pointcloudsFolder = config.configuration["internal-folder"].replace(/\/$/, "");
        }else{

            configurationFile.pointcloudsFolder = join(os.homedir(), "sse-internal");
        }

        configurationFile.setsOfClassesMap = new Map();
        configurationFile.setsOfClasses = config["sets-of-classes"];
        if (!configurationFile.setsOfClasses){
            configurationFile.setsOfClasses = defaultClasses;
        }
        configurationFile.setsOfClasses.forEach(o => configurationFile.setsOfClassesMap.set(o.name, o));