Created
August 30, 2018 17:57
-
-
Save kamnan43/4b7ed2503326e6e82731184c3b01b462 to your computer and use it in GitHub Desktop.
This file contains 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
var fs = require('fs'); | |
var request = require('request'); | |
var formData = { | |
message: 'test message', | |
imageFile: fs.createReadStream('/file/path.jpeg'), | |
}; | |
var options = { | |
method: 'POST', | |
url: 'https://notify-api.line.me/api/notify', | |
headers: { | |
'Authorization': 'Bearer ===YOURTOKEN===' | |
}, | |
formData: formData | |
}; | |
function callback(error, response, body) { | |
if (!error && response.statusCode == 200) { | |
var info = JSON.parse(body); | |
console.log('Upload successful! Server responded with:', info); | |
} else { | |
return console.error('upload failed:', error); | |
} | |
} | |
request(options, callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment