Get media resource as an InputStream, should work regardless of whether you set the media
resource data as an InputStream or as a byte array.
192808
public InputStream getAsStream() throws ProponoException {
        if (getContents() != null && !getContents().isEmpty()) {
            final Content c = getContents().get(0);
            if (c.getSrc() != null) {
                return getResourceAsStream();
            } else if (inputStream != null) {
                return inputStream;
            } else if (bytes != null) {
                return new ByteArrayInputStream(bytes);
            } else {
                throw new ProponoException("ERROR: no src URI or binary data to return");
            }
        } else {
            throw new ProponoException("ERROR: no content found in entry");
        }
    }
1023309
public static byte[] readByteArrayFromResource(String resource) throws IOException {
        InputStream in = getResourceAsStream(resource);
        if (in == null) {
            return null;
        }

        try {
            return readByteArray(in);
        } finally {
            closeQuietly(in);
        }
    }
1251517
def get_resource_data(incoming_request):
    """"""
    content_type = incoming_request.headers['Content-type'].split(';')[0]
    if ('Content-type' not in incoming_request.headers or
            content_type in JSON_CONTENT_TYPES):
        return incoming_request.json
    elif content_type in HTML_CONTENT_TYPES:
        if not incoming_request.form:
            raise InvalidAPIUsage(400)
        return incoming_request.form
    else:
        # HTTP 415: Unsupported Media Type
        raise InvalidAPIUsage(
            415,
            UNSUPPORTED_CONTENT_TYPE_MESSAGE.format(
                types=incoming_request.headers['Content-type']))
459820
private static InputStream inputStreamFromFile(URL resourceUrl)
      throws IOException, URISyntaxException {
    File resourceFile = new File(resourceUrl.toURI());
    return new FileInputStream(resourceFile);
  }
674055
public InputStream getData() {
    if (data != null) {
      return new ByteArrayInputStream(data);
    } else if (dataStream != null) {
      return dataStream;
    } else {
      throw new IllegalStateException("Either the byte[] or the stream mustn't be null at this point.");
    }
  }
693032
private static byte[] getData(String fileName, Object location) throws IOException {

		byte[] data;
		if (location instanceof String) {
			data = FileSupport.getBinaryFromJar(fileName, (String) location);
		} else if (location instanceof File) {
			InputStream in = new FileInputStream((File) location);
			data = StreamSupport.absorbInputStream(in);
			in.close();
		} else {
			throw new NoClassDefFoundError("file '" + fileName + "' could not be loaded from '" + location + '\'');
		}
		return data;
	}
1196543
public static ImageInputStream getImageInputStream(InputStream in) throws IORuntimeException {
		try {
			return ImageIO.createImageInputStream(in);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
242746
static InputStream getFileAsStream(File resourceFile) throws ConfigurationException {
        try {
            return new FileInputStream(resourceFile);
        } catch (FileNotFoundException e) {
            Log.error("File Resource could not be resolved. Given Resource:" + resourceFile, e);
            throw new ConfigurationException("File Resource could not be resolve", FILE_NOT_FOUND_EXCEPTION_ID,e);
        }
    }
26570
private static AudioInputStream openStream(Media media) throws IOException
    {
        try
        {
            return AudioSystem.getAudioInputStream(media.getInputStream());
        }
        catch (final UnsupportedAudioFileException exception)
        {
            throw new IOException(ERROR_PLAY_SOUND + media.getPath(), exception);
        }
    }
389056
@FFDCIgnore({IOException.class})
    public static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
        URL url = getResource(resourceName, callingClass);

        try {
            return (url != null) ? url.openStream() : null;
        } catch (IOException e) {
            return null;
        }
    }
274316
public static InputStream getStream(Class<?> root, String resourceName) {
        return getStream(root, resourceName, false);
    }
1204411
@Override
    public InputStream getResourceAsStream(String name) {
        byte[] b = null;
        try {
            Asset resource = AssetCache.getAsset(mdwPackage.getName() + "/" + name);
            if (resource != null)
                b = resource.getRawContent();
            if (b == null)
                b = findInJarAssets(name);
            if (b == null)
                b = findInFileSystem(name);
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(),  ex);
        }

        if (b == null)
            return super.getResourceAsStream(name);
        else
            return new ByteArrayInputStream(b);
    }
313568
@Override
  public ImageInputStream getImageInputStream(long txid) throws IOException {
    URLImageInputStream stream = loggers.getImageInputStream(txid,
        httpConnectReadTimeoutMs);
    if (stream == null) {
      throw new IOException("Cannot obtain input stream for image: " + txid);
    }
    return new ImageInputStream(txid, stream, stream.getImageDigest(),
        stream.toString(), stream.getSize());
  }
153595
protected byte[] getBinaryData(Resource resource, @SuppressWarnings("unused") SlingHttpServletRequest request) throws IOException {
    InputStream is = resource.adaptTo(InputStream.class);
    if (is == null) {
      return null;
    }
    try {
      return IOUtils.toByteArray(is);
    }
    finally {
      is.close();
    }
  }
1079060
protected JSONArray getResponsiveImageSources(Media media) {
    MediaFormat[] mediaFormats = media.getMediaRequest().getMediaArgs().getMediaFormats();
    JSONArray sources = new JSONArray();
    for (MediaFormat mediaFormat : mediaFormats) {
      sources.put(toReponsiveImageSource(media, mediaFormat));
    }
    return sources;
  }
123910
public static void getTo(
                    final URL from_url,
                    final OutputStream to_stream,
                    final List<MediaType> accept_media_types
                    )
    {
        _LOG_.debug( "HTTP GET: from URL=" + from_url + ", accept=" + accept_media_types );

        AcceptHeaderRequestCallback  callback =
                        new AcceptHeaderRequestCallback( accept_media_types );
        OutputStreamResponseExtractor  extractor = new OutputStreamResponseExtractor( to_stream );
        _execute( from_url, HttpMethod.GET, callback, extractor );
    }
319996
@Override
    public AudioFileFormat getAudioFileFormat(InputStream inputStream, long medialength) throws UnsupportedAudioFileException, IOException {
        return getAudioFileFormat(inputStream, (int) medialength, AudioSystem.NOT_SPECIFIED);
    }