This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Encrypt/Decrypt & Upload a File to S3 #42
Comments
Hi @jelordreygulle below is an example from our dev hub. Take a look and let me know if this helps. const Virtru = require('virtru-sdk');
const AWS = require('aws-sdk');
/**
* Example showing how to encrypt and write a file to S3.
*
* This example assumes you've installed the aws-sdk module and set up your AWS
* credentials file. For more information, see: https://github.com/aws-samples/aws-nodejs-sample
*
* Example usage:
* node sample.js [email protected] $(cat ~/.virtru/appId) hello.txt my-s3-bucket
*
* If your bucket is configured for static website hosting you'll be able to
* open up Secure Reader directly from the object link.
* (e.g., http://my-s3-bucket.s3-website-us-west-2.amazonaws.com/hello.txt.html)
*/
const email = process.argv[2];
const appId = process.argv[3];
const localFilename = process.argv[4];
const bucketName = process.argv[5];
// Initialize the Virtru and S3 clients.
const client = new Virtru.Client({email, appId});
const s3 = new AWS.S3();
// Derive the object key to use by appending .html for easy browser support.
const key = `${localFilename}.html`;
const encryptParams = new Virtru.EncryptParamsBuilder()
.withFileSource(localFilename)
.withDisplayFilename(localFilename)
.build();
// The returned stream can be passed directly to s3.upload().
client.encrypt(encryptParams).then(ct =>
s3.upload({Body: ct, Bucket: bucketName, Key: key, ContentType: 'html/text'}, onComplete));
function onComplete(err, data) {
console.log(`${localFilename} encrypted and uploaded to S3 as ${key}`);
} |
Thank you for this one Sir . |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Do you have some example implementation Sir on Encrypt/Decrypt & Upload a File to S3 using the node js sdk of virtru ? Thanks.
The text was updated successfully, but these errors were encountered: