SHARE
TWEET

Untitled

a guest Feb 9th, 2018 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       options = {
  2.             uri: apiUrl+"files",
  3.             headers: {
  4.               'Authorization': 'Bearer ' + userTokens[usersLeft[0]].token, // Token
  5.               'Content-Type': 'multipart/form-data'
  6.             },
  7.             method: "POST",
  8.             formData:{
  9.               files: fs.createReadStream("data/"+regex[1]+"/"+fileData[regex[1]]["name"]), // File
  10.               channel_id: channelsForUser[0]["id"] // Channel id
  11.             }
  12.           }; // Headder fun.
  13.  
  14.  
  15.          
  16.           request(options, function(error, res, body) { // Send the request and create callback
  17.             options = {// Set the headders for editing the post
  18.                   uri: apiUrl+"posts/"+mid, // Set the uri with the message id
  19.                   headers: {
  20.                     'Authorization': 'Bearer ' + userTokens[usersLeft[0]].token // Token
  21.                   },
  22.                   method: "PUT",
  23.                   json:{ // Payload
  24.                     message: message,
  25.                     file_ids: [JSON.parse(body).file_infos[0].id]
  26.                   }
  27.                 };
  28.                 request(options, function(error, res, body) {
  29.                   // Do other stuff
  30.                 });
  31.  
  32.  
  33.           });
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top