Created
November 22, 2019 07:01
-
-
Save trevorfoskett/32ef6e132ebfafa9d72d85f57a75d3d5 to your computer and use it in GitHub Desktop.
Added upload functionality to the encrypt function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function encrypt(fileName, auth){ | |
const encryptParams = new Virtru.EncryptParamsBuilder() | |
.withFileSource(`./encrypt-in/${fileName}`) | |
.withDisplayFilename(fileName) | |
.build(); | |
ct = await client.encrypt(encryptParams); | |
var ctString = await ct.toString(); | |
const drive = google.drive({version: 'v3', auth}); | |
var fileMetadata = { | |
'name': `${fileName}.tdf3.html`, | |
parents: [folderId] | |
}; | |
var media = { | |
mimeType: 'text/html', | |
body: ctString // Body of file is created with the encrypted string output above. | |
}; | |
drive.files.create({ | |
resource: fileMetadata, | |
media: media, | |
fields: 'id' | |
}, function (err, file) { | |
if (err) { | |
// Handle error | |
console.error(err); | |
console.log(`${fileName} - ERROR.`) | |
} else { | |
console.log(`- ${fileName}`); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment