Skip to content

Instantly share code, notes, and snippets.

@abachuk
Created June 26, 2017 21:47
Show Gist options
  • Save abachuk/0cc5980f24e43153b2e8492737aa6da8 to your computer and use it in GitHub Desktop.
Save abachuk/0cc5980f24e43153b2e8492737aa6da8 to your computer and use it in GitHub Desktop.
node.js using fileUploadMiddleware for streaming files to CDN
import multer from 'multer';
import cloudinary from 'cloudinary';
import fileUploadMiddleware from './fileUploadMiddleware';
/* your servrer init and express code here */
cloudinary.config({
cloud_name: 'xxx',
api_key: 'xxxx',
api_secret: 'xxxxx',
});
/**
* Multer config for file upload
*/
const storage = multer.memoryStorage();
const upload = multer({ storage });
app.post('/files', upload.single('file'), fileUploadMiddleware);
/* the rest of your routes app.get('*', () => {}) */
/* the rest of your server code */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment