1.0.0 • Published 8 years ago

base64-png-uploader v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

base64-png-uploader

Upload a base64 encoded png to S3 or file system. Other cloud storage services could be or not here soon ;) Very useful to use with Test Automation with Selenium to store screenshots taken.

Install

  npm install base64-png-uploader

Usage in S3

var uploader = require('base64-png-uploader');
// if you do not export AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_ID
uploader.awsCredentialsFromPath('path_to_JSON_FILE');
uploader.asS3('BUCKET_NAME');
uploader.store('FILE_NAME|PATH+FILE_NAME', 'BASE_64_ENCODED_PNG', function(error, data){})

For more information about credentials and aws-sdk click here. The callback function will be called from s3.putObject so you maybe want to check documentation.

Usage in filesystem

var uploader = require('base64-png-uploader');
// if you do not export AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_ID
uploader.store('FILE_NAME|PATH+FILE_NAME', 'BASE_64_ENCODED_PNG', function(error){})

The callback function will be called from fs.writeFile so you maybe want to check documentation.

Usage taking a snapshot with selenium

selenium.takeScreenshot()
.then((image, err) => {
  uploader.asS3('BUCKET_NAME').store('FILE_NAME.PNG', image, (err, data) => {
    //do whatever you want after image is saved
    }
  );
});

License

MIT

1.0.0

8 years ago