Guest User

Untitled

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