Guest User

Untitled

a guest
Oct 10th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. // fetch-blob-functions.js
  2.  
  3. var azure = require('azure-storage');
  4. var config = require('./config');
  5. var azure_key = config.azure.key1;
  6. var storage_account = config.azure.storage_account;
  7. var blobSvc = azure.createBlobService(storage_account, azure_key);
  8.  
  9. /**
  10. * Retrieves list of blobs in a collection
  11. * @return{Promise} Fulfilled with array of blob names
  12. */
  13. const listBlobs = async () => {
  14. return new Promise((resolve, reject) => {
  15. blobSvc.listBlobsSegmented([container name], null, (err, data) => {
  16. if (err) {
  17. reject(err);
  18. } else {
  19. console.log(data);
  20. }
  21. });
  22. });
  23. };
  24.  
  25. /**
  26. * Retrieves a blob and saves it to a file
  27. * @return{Promise} Fulfilled with array of blob names
  28. */
  29. const saveBlob = async () => {
  30. return new Promise((resolve, reject) => {
  31. blobSvc.getBlobToText([container name], [blob name], [file name] (err, data) => {
  32. if (err) {
  33. reject(err);
  34. } else {
  35. console.log(data);
  36. }
  37. });
  38. });
  39. };
  40.  
  41. // config.js
  42.  
  43. module.exports = {
  44. remotePathToList: 'data',
  45. localStorageDir: 'data',
  46. connectionSettings: {
  47. host: 'ip_address',
  48. port: 22, // Normal is 22 port
  49. username: 'username',
  50. password: 'password'
  51.  
  52. },
  53. azure: {
  54. storage_account: [account details will be provided],
  55. key1: [key will be provided]
  56. }
  57. };
Add Comment
Please, Sign In to add comment