I'm using openpgp.js to encrypt a s3 getObject
stream. After the encryption I try to upload the encrypted stream using s3.upload()
which results in the error:
S3 upload list[0]" argument must be an instance of Buffer or Uint8Array
The error only shows up if I use the option armor: true
(which I want) in the encryption stream.
Here is the relevant extract from the code:
let encryptionStream = await openpgp.encrypt({
message: pgpMessage,
publicKeys: publicKey,
privateKeys: privateKey,
streaming: 'node',
armor: true
});
var uploadObjectAsync = async (s3Params) => new Promise((resolve, reject) => {
s3.upload(s3Params, (err, data) => {
if(err) reject(err);
resolve(data);
});
});
await uploadObjectAsync({'Bucket': 'test-upload', 'Key': 'encrypted_file', 'Body': encryptionStream, });
I also took a look at this github issue but using encryptionStream.setEncoding(null)
still results in the same error
https://github.com/aws/aws-sdk-js/issues/2081