5.2 Transferring files using SecureS3

5.2.1 Initialize the SecureS3 object

var secureS3 = new SecureS3(
        "<bayunSessionId>",  // bayun sessionId will be returned when user successfully able to signIn.
        "<apiVersion>",  // provided on AWS console
        "<accessKeyId>", // provided on AWS console
        "<secretAccessKey>", // provided on AWS console
        "<signatureVersion>", // provided on AWS console
        "<region>", // provided on AWS console
        "<bucket>", // provided on AWS console
);

//set EncryptionPolicy and keyGenerationPolicy by these methods which are going
//to be used while locking/encrypting a file before uploading to s3.
secureS3.setEncryptionPolicy(BayunCore.EncryptionPolicy.EMPLOYEE);
secureS3.setKeyGenerationPolicy(BayunCore.KeyGenerationPolicy.ENVELOPE);
    

5.2.2 Upload a File to Amazon S3 using secureS3 object

var file = "<fileToBeUpload>" //document.getElementById("file").files[0];
await secureS3.upload(file);

5.2.3 Download a File from Amazon S3 using secureS3 object

await secureS3.downloadFile("<yourFileName.extension>"); // we can get uploaded filename from AWS buckets console

By doing the above, all data written to S3 is automatically locked before upload and unlocked after download in such a manner that nobody other than the customer (and especially the developer) has access to any of the encryption keys or the data itself.

Last updated