@Override public byte[] getByteArray() throws IOException { return blob.getByteArray(); }
public DocumentBlob(String name, Blob blob) throws IOException { this.blob = blob.getByteArray(); encoding = blob.getEncoding(); mimeType = blob.getMimeType(); this.name = name; }
try { byte[] bytes = ((Blob) value).getByteArray(); strValue = Base64.encodeBase64String(bytes); } catch (IOException e) {
@Override public String persist(String basePath) throws IOException { Path path = new Path(basePath); path = path.append(getHash()); File dir = new File(path.toString()); dir.mkdir(); ZipUtils.unzip(zipBlob.getStream(), dir); key = dir.getAbsolutePath(); // Check if creating an index.html file is needed load(path.toString()); if (blobs != null && !blobs.get(0).getFilename().contains("index.html")) { log.info("Any index.html file found, generate a listing as index page."); File index = new File(dir, "index.html"); if (index.createNewFile()) { Blob indexBlob = createIndexBlob(); blobs.add(0, indexBlob); FileUtils.writeByteArrayToFile(index, indexBlob.getByteArray()); } else { log.info("Unable to create index.html file"); } } return key; }
try { byte[] bytes = ((Blob) value).getByteArray(); strValue = Base64.encodeBase64String(bytes); } catch (IOException e) {
response.addHeader("Cache-Control", "public"); response.setContentType(imgBlob.getMimeType()); response.getOutputStream().write(imgBlob.getByteArray()); response.getOutputStream().close(); response.flushBuffer();
byte[] bytes = blob.getByteArray();
Blob blob = (Blob) input.getValue(); try { record.put(f.name(), ByteBuffer.wrap(blob.getByteArray())); } catch (IOException e) { throw new RuntimeServiceException(CANNOT_MAP_TO + schema.getType(), e);
} else if ("content".equals(typeName)) { try { attribute.add(((Blob) value).getByteArray()); } catch (IOException e) { throw new DirectoryException("Failed to get ByteArray value", e);
protected final void readBlob(Element element, ComplexType ctype, Blob blob, boolean inlineBlobs) throws IOException { String blobPath = Integer.toHexString(RANDOM.nextInt()) + ".blob"; element.addElement(ExportConstants.BLOB_ENCODING).addText(blob.getEncoding() != null ? blob.getEncoding() : ""); element.addElement(ExportConstants.BLOB_MIME_TYPE) .addText(blob.getMimeType() != null ? blob.getMimeType() : ""); element.addElement(ExportConstants.BLOB_FILENAME).addText(blob.getFilename() != null ? blob.getFilename() : ""); Element data = element.addElement(ExportConstants.BLOB_DATA); if (inlineBlobs) { String content = Base64.encodeBase64String(blob.getByteArray()); data.setText(content); } else { data.setText(blobPath); blobs.put(blobPath, blob); } element.addElement(ExportConstants.BLOB_DIGEST).addText(blob.getDigest() != null ? blob.getDigest() : ""); }