我有一个JsonNode数组,我正在尝试将其压缩并上传到s3。下面是我的代码,它给了我下面的错误
om.fasterxml.jackson.databind.exc.InvalidDefinitionException:找不到类java.io.ObjectOutputStream的序列化程序,也找不到创建BeanSerializer的属性(为避免异常,请禁用SerializationFeature.FAIL_ON_EMPTY_BEANS(
在下面的代码中,有效载荷是JsonNode[]
GzipCompressorOutputStream gzip = new GzipCompressorOutputStream(obj);
ObjectOutputStream objectOutputStream = new ObjectOutputStream(gzip);
for(JsonNode record:payload) {
objectOutputStream.writeObject(record);
}
// gzip.flush();
// gzip.close();
objectOutputStream.close();
ObjectMapper objectMapper = new ObjectMapper();
//objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
byte[] bytesToWrite = objectMapper.writeValueAsBytes(objectOutputStream);
ObjectMetadata omd = new ObjectMetadata();
//omd.setContentType("application/x-gzip");
omd.setContentLength(bytesToWrite.length);
// transferManager.upload(bucketName, keyName, new ByteArrayInputStream(bytesToWrite), omd);
s3.putObject(bucketName, keyName, new ByteArrayInputStream(bytesToWrite), omd);
ObjectMapper objectMapper = new ObjectMapper();
byte[] bytesToWrite = objectMapper.writeValueAsBytes(payload);
ByteArrayOutputStream obj=new ByteArrayOutputStream();
GzipCompressorOutputStream gzip = new GzipCompressorOutputStream(obj);
gzip.write(bytesToWrite);
gzip.flush();
gzip.close();
ObjectMetadata omd = new ObjectMetadata();
omd.setContentType("application/x-gzip");
omd.setContentLength(obj.toByteArray().length);
s3.putObject(bucketName, keyName, new ByteArrayInputStream(obj.toByteArray()), omd);