mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-31 04:18:39 +00:00
add control over the base64 variant
This commit is contained in:
parent
913a486f99
commit
651cd78456
.idea/dictionaries
plugins/attachments/src/main/java/org/elasticsearch/plugin/attachments/index/mapper
1
.idea/dictionaries/kimchy.xml
generated
1
.idea/dictionaries/kimchy.xml
generated
@ -30,6 +30,7 @@
|
|||||||
<w>joda</w>
|
<w>joda</w>
|
||||||
<w>jsonp</w>
|
<w>jsonp</w>
|
||||||
<w>lifecycle</w>
|
<w>lifecycle</w>
|
||||||
|
<w>linefeeds</w>
|
||||||
<w>lucene</w>
|
<w>lucene</w>
|
||||||
<w>metadata</w>
|
<w>metadata</w>
|
||||||
<w>millis</w>
|
<w>millis</w>
|
||||||
|
@ -21,6 +21,8 @@ package org.elasticsearch.plugin.attachments.index.mapper;
|
|||||||
|
|
||||||
import org.apache.tika.exception.TikaException;
|
import org.apache.tika.exception.TikaException;
|
||||||
import org.apache.tika.metadata.Metadata;
|
import org.apache.tika.metadata.Metadata;
|
||||||
|
import org.codehaus.jackson.Base64Variant;
|
||||||
|
import org.codehaus.jackson.Base64Variants;
|
||||||
import org.codehaus.jackson.JsonParser;
|
import org.codehaus.jackson.JsonParser;
|
||||||
import org.codehaus.jackson.JsonToken;
|
import org.codehaus.jackson.JsonToken;
|
||||||
import org.elasticsearch.index.mapper.FieldMapperListener;
|
import org.elasticsearch.index.mapper.FieldMapperListener;
|
||||||
@ -166,6 +168,7 @@ public class JsonAttachmentMapper implements JsonMapper {
|
|||||||
byte[] content = null;
|
byte[] content = null;
|
||||||
String contentType = null;
|
String contentType = null;
|
||||||
String name = null;
|
String name = null;
|
||||||
|
Base64Variant base64Variant = Base64Variants.getDefaultVariant();
|
||||||
|
|
||||||
JsonParser jp = jsonContext.jp();
|
JsonParser jp = jsonContext.jp();
|
||||||
JsonToken token = jp.getCurrentToken();
|
JsonToken token = jp.getCurrentToken();
|
||||||
@ -178,11 +181,20 @@ public class JsonAttachmentMapper implements JsonMapper {
|
|||||||
currentFieldName = jp.getCurrentName();
|
currentFieldName = jp.getCurrentName();
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("content".equals(currentFieldName)) {
|
if ("content".equals(currentFieldName)) {
|
||||||
content = jp.getBinaryValue();
|
content = jp.getBinaryValue(base64Variant);
|
||||||
} else if ("_content_type".equals(currentFieldName)) {
|
} else if ("_content_type".equals(currentFieldName)) {
|
||||||
contentType = jp.getText();
|
contentType = jp.getText();
|
||||||
} else if ("_name".equals(currentFieldName)) {
|
} else if ("_name".equals(currentFieldName)) {
|
||||||
name = jp.getText();
|
name = jp.getText();
|
||||||
|
} else if ("_base64".equals(currentFieldName)) {
|
||||||
|
String variant = jp.getText();
|
||||||
|
if ("mime".equals(variant)) {
|
||||||
|
base64Variant = Base64Variants.MIME;
|
||||||
|
} else if ("mime_no_linefeeds".equals(variant)) {
|
||||||
|
base64Variant = Base64Variants.MIME_NO_LINEFEEDS;
|
||||||
|
} else {
|
||||||
|
throw new MapperParsingException("Can't handle base64 [" + variant + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user