embulk-output-s3_per_record 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88cdda711509c0f8890ae1dfa9c9720c1067bd0b
4
- data.tar.gz: 1618f1e1d874773f3edcaa738bd1f4bd4d4c766e
3
+ metadata.gz: 66c630852cd7438c47f5c7d4ce90e5ae9c260c28
4
+ data.tar.gz: 7485c4a4d693740fb7f6ef9975d31ab3f63522fc
5
5
  SHA512:
6
- metadata.gz: 1b2b9029f619efcb751886b52d755cfd8bf11750a87c6a98c4f9561a539083ec78ece754fe1d2fa19be646fb2d3d677488207b2b1cbb31c4405b181c56bd5c53
7
- data.tar.gz: 1c39b5d32160d7e2290bba51c376971131f44a5d81159db285340119c1d28970d984d05d5ba2dc8c569189189e242722241136965a8e92c6926cd5143d75d9f6
6
+ metadata.gz: d05834b8904544d92f524e09919dd8fc6793da6243a76c43056da0d8c16d025534ab5d4d036c63625acd61545a907e8bda4431312f072f66df66cdde8dc42858
7
+ data.tar.gz: 9181a74cc5ccd62a19090d864f96697ee74b7c0b4defeb2158b51fe4f02f7c9c89b146b105d67ecf34efc2b567d290fb7aaa84b29b69aa0726e5a714f26bc406
data/README.md CHANGED
@@ -16,6 +16,7 @@ S3 object key can be composed of another column.
16
16
  - **data_column**: Column for object's body.
17
17
  - **aws_access_key_id**: (optional) AWS access key id. If not given, [DefaultAWSCredentialsProviderChain](http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html) is used to get credentials.
18
18
  - **aws_secret_access_key**: (optional) AWS secret access key. Required if `aws_access_key_id` is given.
19
+ - **base64**: (default false) If true, decode the value as Base64 before uploading.
19
20
 
20
21
  ## Example
21
22
 
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.0"
16
+ version = "0.1.1"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -3,6 +3,7 @@ package org.embulk.output.s3_per_record;
3
3
  import java.io.ByteArrayInputStream;
4
4
  import java.io.IOException;
5
5
  import java.io.InputStream;
6
+ import java.nio.charset.StandardCharsets;
6
7
  import java.util.ArrayList;
7
8
  import java.util.List;
8
9
 
@@ -29,6 +30,7 @@ import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
29
30
  import com.amazonaws.services.s3.model.ObjectMetadata;
30
31
  import com.amazonaws.services.s3.transfer.TransferManager;
31
32
  import com.amazonaws.services.s3.transfer.Upload;
33
+ import com.amazonaws.util.Base64;
32
34
  import com.google.common.base.Optional;
33
35
 
34
36
 
@@ -63,6 +65,11 @@ public class S3PerRecordOutputPlugin
63
65
  @Config("aws_secret_access_key")
64
66
  @ConfigDefault("null")
65
67
  Optional<String> getAwsSecretAccessKey();
68
+
69
+ // Enable Base64 decoding
70
+ @Config("base64")
71
+ @ConfigDefault("false")
72
+ boolean getBase64();
66
73
  }
67
74
 
68
75
  @Override
@@ -107,12 +114,14 @@ public class S3PerRecordOutputPlugin
107
114
  private final Column dataColumn;
108
115
  private final Schema schema;
109
116
  private List<Upload> uploads;
117
+ private final boolean decodeBase64;
110
118
 
111
119
  public S3PerRecordPageOutput(PluginTask task, Schema schema) {
112
120
  this.schema = schema;
113
121
  bucket = task.getBucket();
114
122
  keyPattern = makeKeyPattern(task.getKey());
115
123
  dataColumn = schema.lookupColumn(task.getDataColumn());
124
+ decodeBase64 = task.getBase64();
116
125
 
117
126
  AWSCredentials credentials;
118
127
  if (task.getAwsAccessKeyId().isPresent() && task.getAwsSecretAccessKey().isPresent()) {
@@ -157,7 +166,12 @@ public class S3PerRecordOutputPlugin
157
166
  String key = buildKey(pageReader);
158
167
 
159
168
  String payload = pageReader.getString(dataColumn);
160
- byte[] payloadBytes = payload.getBytes();
169
+ byte[] payloadBytes;
170
+ if (decodeBase64) {
171
+ payloadBytes = Base64.decode(payload);
172
+ } else {
173
+ payloadBytes = payload.getBytes(StandardCharsets.UTF_8);
174
+ }
161
175
  ObjectMetadata metadata = new ObjectMetadata();
162
176
  metadata.setContentLength(payloadBytes.length);
163
177
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-s3_per_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomykaira
@@ -64,7 +64,7 @@ files:
64
64
  - classpath/commons-codec-1.6.jar
65
65
  - classpath/aws-java-sdk-s3-1.10.71.jar
66
66
  - classpath/aws-java-sdk-core-1.10.71.jar
67
- - classpath/embulk-output-s3_per_record-0.1.0.jar
67
+ - classpath/embulk-output-s3_per_record-0.1.1.jar
68
68
  - classpath/httpcore-4.3.3.jar
69
69
  - classpath/aws-java-sdk-kms-1.10.71.jar
70
70
  homepage: https://github.com/tomykaira/embulk-output-s3_per_record