Java Code Examples for com.google.appengine.api.datastore.Blob#getBytes()
The following examples show how to use
com.google.appengine.api.datastore.Blob#getBytes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServletResponseResultWriter.java From endpoints-java with Apache License 2.0 | 5 votes |
private static SimpleModule getWriteBlobAsBase64Module() { JsonSerializer<Blob> dateSerializer = new JsonSerializer<Blob>() { @Override public void serialize(Blob value, JsonGenerator jgen, SerializerProvider provider) throws IOException { byte[] bytes = value.getBytes(); jgen.writeBinary(bytes, 0, bytes.length); } }; SimpleModule writeBlobAsBase64Module = new SimpleModule("writeBlobAsBase64Module", new Version(1, 0, 0, null, null, null)); writeBlobAsBase64Module.addSerializer(Blob.class, dateSerializer); return writeBlobAsBase64Module; }
Example 2
Source File: ExceptionRecord.java From appengine-pipelines with Apache License 2.0 | 5 votes |
public ExceptionRecord(Entity entity) { super(entity); Blob serializedExceptionBlob = (Blob) entity.getProperty(EXCEPTION_PROPERTY); byte[] serializedException = serializedExceptionBlob.getBytes(); try { exception = (Throwable) SerializationUtils.deserialize(serializedException); } catch (IOException e) { throw new RuntimeException("Failed to deserialize exception for " + getKey(), e); } }
Example 3
Source File: StringDataTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test public void testBlobType() { String propertyName = "blobProp"; List<Entity> elist = doQuery(kindName, propertyName, null, false); Blob blob = (Blob) elist.get(0).getProperty(propertyName); Blob sameDat = (Blob) elist.get(0).getProperty(propertyName); Blob diffDat = (Blob) elist.get(1).getProperty(propertyName); assertTrue(blob.equals(sameDat)); assertFalse(blob.equals(diffDat)); byte[] blobData = blob.getBytes(); assertTrue(Arrays.equals("blobImage".getBytes(), blobData) || Arrays.equals("blobText".getBytes(), blobData) || Arrays.equals("blobData".getBytes(), blobData)); assertEquals(blob.hashCode(), blob.hashCode()); }
Example 4
Source File: FanoutTaskRecord.java From appengine-pipelines with Apache License 2.0 | 4 votes |
public FanoutTaskRecord(Entity entity) { super(entity); Blob payloadBlob = (Blob) entity.getProperty(PAYLOAD_PROPERTY); payload = payloadBlob.getBytes(); }