Skip to content

Instantly share code, notes, and snippets.

@alanhoff
Last active August 29, 2015 14:06
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 alanhoff/6630b02e4177f098e225 to your computer and use it in GitHub Desktop.
Save alanhoff/6630b02e4177f098e225 to your computer and use it in GitHub Desktop.
Recebendo uploads com Hapi.js
server.route({
method: 'POST',
path: '/submit',
config: {
payload: {
output: 'file', // Vamos receber arquivos
parse: true, // Fazer o parse dos campos
allow: 'multipart/form-data' // Só podemos receber forms
maxBytes: 10000000 // Limite de 10MB,
uploads: __dirname + '/../uploads' // diretório onde guardar os arquivos
},
handler: function(request, reply) {
var data = request.payload;
// teus dados devem estar aqui dentro agora
console.log(data);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment