protected InputStream getAsStream(ReferenceService referenceService, T2Reference t2Reference) { Identified identified = referenceService.resolveIdentifier(t2Reference, null, null); if (identified instanceof ReferenceSet) { ExternalReferenceSPI ref = ((ReferenceSet) identified).getExternalReferences().iterator().next(); return ref.openStream(invocationContext); } return null; }
public static MagicMatch getMagicMatch(ExternalReferenceSPI externalReference, InvocationContext context) { InputStream inputStream = externalReference.openStream(context); byte[] bytes = null; MagicMatch magicMatch = null;
private String getMimeType(ExternalReferenceSPI externalReference, InvocationContext context) { if (!mimeTypes.containsKey(externalReference)) { InputStream inputStream = externalReference.openStream(context); try { byte[] bytes = new byte[64]; inputStream.read(bytes); mimeTypes.put(externalReference, Magic.getMagicMatch(bytes, true).getMimeType()); } catch (IOException e) { e.printStackTrace(); logger.debug("Failed to read from stream to determine mimetype", e); } catch (MagicParseException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } catch (MagicMatchNotFoundException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } catch (MagicException e) { e.printStackTrace(); logger.debug("Error calling mime magic", e); } finally { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); logger.debug("Failed to close stream after determining mimetype", e); } } } return mimeTypes.get(externalReference); }
public static String getMimeType(ExternalReferenceSPI externalReference, InvocationContext context) { InputStream inputStream = externalReference.openStream(context); byte[] bytes = null; String mimeType = null;
if (initialBuilder != null && sourceReference != null) { ExternalReferenceSPI builtReference = initialBuilder .createReference(sourceReference.openStream(context), context); results.add(builtReference);
if (initialBuilder != null && sourceReference != null) { ExternalReferenceSPI builtReference = initialBuilder.createReference( sourceReference.openStream(context), context); results.add(builtReference); currentReference = builtReference;
if (initialBuilder != null && sourceReference != null) { ExternalReferenceSPI builtReference = initialBuilder .createReference(sourceReference.openStream(context), context); results.add(builtReference);
mimeUtil .registerMimeDetector("eu.medsea.mimeutil.detector.ExtraMimeTypes"); InputStream inputStream = externalReference.openStream(context); try { byte[] bytes = new byte[2048]; // need to read this much if we want to detect SVG using the hack below
FileOutputStream fileOutputStream = new FileOutputStream(targetFile); InputStream openStream = externalReferences.get(0) .openStream(context); IOUtils.copyLarge(openStream, fileOutputStream); try {
dataStream = externalReferences.get(0).openStream(context);
.openStream(context), cheapestReference.getDataNature(), cheapestReference.getCharset());