public byte[] getProfileImage() { Object image = this.map.get(field_profile_image); if (image == null) return null; try { return Base64.decode((String) image); } catch (IOException e) { return null; } }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode(String s) throws java.io.IOException { return decode(s, NO_OPTIONS); }
/** * Low-level access to decoding ASCII characters in * the form of a byte array. <strong>Ignores GUNZIP option, if * it's set.</strong> This is not generally a recommended method, * although it is used internally as part of the decoding process. * Special case: if len = 0, an empty array is returned. Still, * if you need more speed and reduced memory footprint (and aren't * gzipping), consider this method. * * @param source The Base64 encoded data * @return decoded data * @since 2.3.1 */ public static byte[] decode(byte[] source) throws java.io.IOException { byte[] decoded = null; // try { decoded = decode(source, 0, source.length, Base64.NO_OPTIONS); // } catch( java.io.IOException ex ) { // assert false : "IOExceptions only come from GZipping, which is turned off: " + ex.getMessage(); // } return decoded; }
public byte[] get(Object key) { ElasticsearchSample s = index.get(key); if (s == null) { return null; } Object data = s.get(DATA); byte[] bytes; try { bytes = Base64.decode(String.valueOf(data).getBytes()); } catch (IOException e) { throw new RuntimeException(e); } return bytes; }
@Override public byte[] render(String view, @Nullable Map<String, Object> vars) { byte[] result = new byte[0]; if (vars != null) { Object binary = getBinaryField(view, vars); if (binary != null) { if (binary instanceof String) { try { result = Base64.decode((String) binary); } catch (IOException e) { //todo gérer exception } } } } return result; }
bytes = decode(bytes, 0, bytes.length, options);
@Override public byte[] render(String view, @Nullable Map<String, Object> vars) { byte[] result = new byte[0]; if (vars != null) { Object binary = getBinaryField(view, vars); if (binary != null) { if (binary instanceof String) { try { result = Base64.decode((String) binary); } catch (IOException e) { //todo gérer exception } } } } return result; }
protected Map<String, Object> parseQuery(String source) { try { byte[] bytes = Base64.decode(source); return this.parseQuery(new BytesArray(bytes, 0, bytes.length)); } catch (IOException e) { throw new ElasticsearchParseException("Failed to parse source [" + source + "]", e); } }
return new String(Base64.decode(authInfo)); } catch (IOException e) { logger.debug("Http Basic credentials: [{}] impossible to base 64 decode.", authInfo);
return new String(Base64.decode(authInfo)); } catch (IOException e) { logger.debug("Http Basic credentials: [{}] impossible to base 64 decode.", authInfo);
static ParsedScrollId parseScrollId(String scrollId) { CharsRefBuilder spare = new CharsRefBuilder(); try { byte[] decode = Base64.decode(scrollId, Base64.URL_SAFE); spare.copyUTF8Bytes(decode, 0, decode.length); } catch (Exception e) {
} else { try { bytes = new BytesArray(Base64.decode(value.toString())); } catch (IOException e) { throw new ElasticsearchParseException("failed to convert bytes", e);