Guest User

Untitled

a guest
Oct 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. var signature = getMessageSignature(path, params, nonce);
  2.  
  3. var headers = {
  4. 'Content-Type': 'application/x-www-form-urlencoded',
  5. 'Apiauth-Key': config.key,
  6. 'Apiauth-Nonce': nonce,
  7. 'Apiauth-Signature': signature
  8. };
  9.  
  10.  
  11. return rawRequest(rUrl, headers, params, method, callback);
  12.  
  13. function getMessageSignature(path, params, nonce) {
  14. var data_params = params;
  15.  
  16.  
  17. var postParameters = querystring.stringify(data_params);
  18. var check = {}
  19. var path = '/api' + path + '/';
  20.  
  21. var message = nonce + config.key + path + postParameters;
  22.  
  23. var auth_hash = crypto.createHmac("sha256", config.secret).update(message).digest('hex').toUpperCase();
  24. return auth_hash;
  25. }
  26.  
  27. var options = {
  28. url: url + '/',
  29. headers: headers,
  30. form: params
  31. };
  32.  
  33. request.post(options, function(err, res, body){
  34. ...
  35. ...
  36. })
  37.  
  38. var form = req.form();
  39.  
  40. form.append('file', image, {
  41. filename: 'myfile.png',
  42. enctype: 'multipart/form-data'
  43. });
  44.  
  45. var image = new Buffer(binar_image, 'base64');
Add Comment
Please, Sign In to add comment