Skip to content

Instantly share code, notes, and snippets.

@noppolp
Created May 17, 2015 09:24
Show Gist options
  • Select an option

  • Save noppolp/00f87743ffbb0dfd532b to your computer and use it in GitHub Desktop.

Select an option

Save noppolp/00f87743ffbb0dfd532b to your computer and use it in GitHub Desktop.
Upload file using restler
var rest = require('restler');
var FileInfo = require('./FileInfo.js');
var file = new FileInfo([FULL PATH OF YOUR FILE]);
rest.post([API_ULR], {
multipart: true,
data: {
file: rest.file(file.fullPath, file.name, file.size, null, file.contentType)
},
}).on('complete', function(data, response) {
if (response.statusCode == 201) {
console.log('upload success');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment