我使用以下代码将加密数据写入Amazon:
byte[] bytes = compressFile(instr, CompressionAlgorithmTags.ZIP);
PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5).setWithIntegrityPacket(withIntegrityCheck).setSecureRandom(new SecureRandom()).setProvider("BC"));
encGen.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(pubKey).setProvider("BC"));
OutputStream cOut = encGen.open(out, bytes.length);
cOut.write(bytes);
cOut.close();如果我将“输出”设置为:
final OutputStream fsOutStr = new FileOutputStream(new File("/home/hadoop/encrypted.gpg"));它把文件写得很好。
然而,当我试图将它写到S3时,它不会给我任何错误,似乎是有效的,但是当我检查它时,没有关于S3的数据:
final FileSystem fileSys = FileSystem.get(new URI(GenericUtils.getAsEncodedStringIfEmbeddedSpaces(s3OutputDir)), new Configuration());
final OutputStream fsOutStr = fileSys.create(new Path(s3OutputDir)); // outputPath on S3知道为什么它将数据写入本地磁盘而不将文件写入S3吗?
发布于 2015-04-16 18:45:42
关闭fsOutStr解决了问题。
https://stackoverflow.com/questions/29502879
复制相似问题