Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options = {
- uri: apiUrl+"files",
- headers: {
- 'Authorization': 'Bearer ' + userTokens[usersLeft[0]].token, // Token
- 'Content-Type': 'multipart/form-data'
- },
- method: "POST",
- formData:{
- files: fs.createReadStream("data/"+regex[1]+"/"+fileData[regex[1]]["name"]), // File
- channel_id: channelsForUser[0]["id"] // Channel id
- }
- }; // Headder fun.
- request(options, function(error, res, body) { // Send the request and create callback
- options = {// Set the headders for editing the post
- uri: apiUrl+"posts/"+mid, // Set the uri with the message id
- headers: {
- 'Authorization': 'Bearer ' + userTokens[usersLeft[0]].token // Token
- },
- method: "PUT",
- json:{ // Payload
- message: message,
- file_ids: [JSON.parse(body).file_infos[0].id]
- }
- };
- request(options, function(error, res, body) {
- // Do other stuff
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement