Socket
Socket
Sign inDemoInstall

flowjs-express

Package Overview
Dependencies
19
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    flowjs-express

experimental express 4 flow.js server-side component(s)


Version published
Maintainers
1
Created

Readme

Source

FlowJS for Express

This module is experimental - use at own risk - cobbled together from various online sources I've come across.

Code snippet to start with, not that you probably can't copy paste - read it over until I get real documentation.

var temporaryFolder = path.resolve(path.join('./', 'uploads-tmp'));
var flow = require('flowjs-express')(temporaryFolder);
var saveFolder = path.resolve(path.join('./', 'uploads'));

app.post('/uploads', flow.post, function(req, res, next) {
	log.debug('req.flow.status', req.flow.status);
	if (req.flow.status === 'done') {

		// req.flow is populated with great info
		console.log('Upload Done', req.flow);
		
		var file_ext = path.extname(req.flow.filename);
		var save_path = path.join(saveFolder, 'custom-name' + file_ext);

	    var saveStream = fs.createWriteStream(save_path);
	    flow.write(req.flow.identifier, saveStream);

	    saveStream.on('finish', function() {
	    	// file is finished writing
	    	res.send(save_path);

	    }).on('error', function(err) {
	    	res.sendStatus(400);
	    });

	} else {
		res.sendStatus(200);
	}
});

FAQs

Last updated on 30 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc