src/main/java/org/embulk/input/gcs/GcsFileInput.java in embulk-input-gcs-0.3.1 vs src/main/java/org/embulk/input/gcs/GcsFileInput.java in embulk-input-gcs-0.3.2
- old
+ new
@@ -78,20 +78,28 @@
LOG.warn(e.getMessage());
}
return builder.build();
}
- // String nextToken = base64Encode(0x0a + 0x01~0x27 + filePath);
+ // String nextToken = base64Encode(0x0a + ASCII character according to utf8EncodeLength position+ filePath);
@VisibleForTesting
static String base64Encode(String path)
{
byte[] encoding;
byte[] utf8 = path.getBytes(Charsets.UTF_8);
LOG.debug("path string: {} ,path length:{} \" + ", path, utf8.length);
+ int utf8EncodeLength = utf8.length;
+ if (utf8EncodeLength >= 128) {
+ throw new ConfigException(String.format("last_path '%s' is too long to encode. Please try to reduce its length", path));
+ }
+
encoding = new byte[utf8.length + 2];
encoding[0] = 0x0a;
- encoding[1] = Byte.valueOf(String.valueOf(path.length()));
+
+ // for example: 60 -> '<'
+ char temp = (char) utf8EncodeLength;
+ encoding[1] = (byte) temp;
System.arraycopy(utf8, 0, encoding, 2, utf8.length);
String s = BaseEncoding.base64().encode(encoding);
LOG.debug("last_path(base64 encoded): {}", s);
return s;