Skip to content

Instantly share code, notes, and snippets.

@benjick
Last active July 13, 2016 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjick/fea6435c8ce3e33ee6038628f87944d4 to your computer and use it in GitHub Desktop.
Save benjick/fea6435c8ce3e33ee6038628f87944d4 to your computer and use it in GitHub Desktop.
app.post('/upload', multipartMiddleware, (req, res) => { // multipartMiddleware is for multipart forms
console.log(req.body);
res.json({
foo: 'bar',
});
});
const formData = new FormData();
formData.append('file', { uri, type: 'image/jpg' }); // uri is the image from https://github.com/lwansbrough/react-native-camera
fetch('http://localhost:3000/upload', {
method: 'POST',
body: formData,
// header: {
// 'Content-Type': 'multipart/form-data',
// },
})
req.body { file: '����\u0000\u0010JFIF\u0000\u0001\u0001\u0000\u0000H\u0000H\u0000\u0000��\u0000XExif\u0000\u0000MM\u0000*\u0000\u0000\u0000\b\u0000\u0002\u0001\u0012\u0000\u0003\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000�i\u0000\u0004\u0000\u0000\u0000\u0001\u0000\u0000\u0000&\u0000\u0000\u0000\u0000\u0000\u0003�\u0001\u0000\u0003\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000�\u0002\u0000\u0004\u0000\u0000\u0000\u0001\u0000\u0000\u00008�\u0003\u0000\u0004\u0000\u0000\u0000\u0001\u0000\u0000\u0000d\u0000\u0000\u0000\u0000��\u00008Photoshop 3.0\u00008BIM\u0004\u0004\u0000\u0000\u0000\u0000\u0000\u00008BIM\u0004%\u0000\u0000\u0000\u0000\u0000\u0010�\u001d�ُ\u0000�\u0004�\t���B~��\u0000\u0011\b\u0000d\u00008\u0003\u0001"\u0000\u0002\u0011\u0001\u0003\u0011\u0001��\u0000\u001f\u0000\u0000\u0001\u0005\u0001\u0001\u0001\u0001\u0001\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b��\u0000�\u0010\u0000\u0002\u0001\u0003\u0003\u0002\u0004\u0003\u0005\u0005\u0004\u0004\u0000\u0000\u0001}\u0001\u0002\u0003\u0000\u0004\u0011\u0005\u0012!1A\u0006\u0013Qa\u0007"q\u00142���\b#B��\u0015R��$3br�\t\n\u0016\u0017\u0018\u0019\u001a%&\'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������\u0000\u001f\u0001\u0000\u0003\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b��\u0000�\u0011\u0000\u0002\u0001\u0002\u0004\u0004\u0003\u0004\u0007\u0005\u0004\u0004\u0000\u0001\u0002w\u0000\u0001\u0002\u0003\u0011\u0004\u0005!1\u0006\u0012AQ\u0007aq\u0013"2�\b\u0014B����\t#3R�\u0015br�\n\u0016$4�%�\u0017\u0018\u0019\u001a&\'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������\u0000C\u0000\u0004\u0004\u0004\u0004\u0004\u0004\u0006\u0004\u0004\u0006\t\u0006\u0006\u0006\t\f\t\t\t\t\f\u000f\f\f\f\f\f\u000f\u0012\u000f\u000f\u000f\u000f\u000f\u000f\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0015\u0015\u0015\u0015\u0015\u0015\u0019\u0019\u0019\u0019\u0019\u001c\u001c\u001c\u001c\u001c\u001c\u001c\u001c\u001c\u001c��\u0000C\u0001\u0004\u0005\u0005\u0007\u0007\u0007\f\u0007\u0007\f\u001d\u0014\u0010\u0014\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d\u001d��\u0000\u0004\u0000\u0004��\u0000\f\u0003\u0001\u0000\u0002\u0011\u0003\u0011\u0000?\u0000���(���`��(\u0000��(\u0000��(\u0003�����(���`��(\u0000��(\u0000��(\u0003�����(���`��(\u0000��(\u0000��(\u0003�����(���b\u0019<�ߺ+�w��\u0005�FY1��;��\u0014Pf���쯋�U���ɿo�Aoju\u0014\u000e0��Š(�������(���`��(\u0000��(\u0000��(\u0003�����(���`��(\u0000��(\u0000��(\u0003�����(���`��(\u0000��(\u0000��(\u0003��' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment