Created
June 26, 2017 21:47
-
-
Save abachuk/0cc5980f24e43153b2e8492737aa6da8 to your computer and use it in GitHub Desktop.
node.js using fileUploadMiddleware for streaming files to CDN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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