private void handleContent(
     DocumentDTO docDTO, YContentEntry content, ZipArchive currentZipArchive) {
   if (content.isFile()) {
     YContentFile yFile = (YContentFile) content;
     if (BWMetaConstants.mimePdfListExtension.contains(yFile.getFormat())) {
       fetchMediaFromZip(docDTO, yFile, currentZipArchive, ProtoConstants.mediaTypePdf);
     } else if (BWMetaConstants.mimeTxtListExtension.contains(yFile.getFormat())) {
       fetchMediaFromZip(docDTO, yFile, currentZipArchive, ProtoConstants.mediaTypeTxt);
     }
   }
 }
  private void fetchMediaFromZip(
      DocumentDTO docDTO, YContentFile yFile, ZipArchive currentZipArchive, String mediaType) {
    for (String location : yFile.getLocations()) {
      // path to media in yFile contains prefix yadda.pack:/, check and remove it
      String prefix = "yadda.pack:/";
      if (location.startsWith(prefix)) {
        location = location.substring(prefix.length());
        // path to media in zip file contains zip filename, not included in yFile
        List<String> foundPaths = currentZipArchive.filter(".*" + location);
        // foundPaths should contain 1 item
        if (foundPaths.size() > 0) {
          try {
            String foundPath = foundPaths.get(0);
            InputStream mediaIS = currentZipArchive.getFileAsInputStream(foundPath);
            // ... do something with mediaIS
            Media.Builder mediaBuilder = Media.newBuilder();
            mediaBuilder.setKey(docDTO.getKey());
            // Media and Document should have the same key?
            mediaBuilder.setMediaType(mediaType);
            byte[] content = IOUtils.toByteArray(mediaIS);
            mediaBuilder.setContent(ByteString.copyFrom(content));
            mediaBuilder.setSourcePath(currentZipArchive.getZipFilePath() + "#" + foundPath);
            mediaBuilder.setSourceFilesize(content.length);

            docDTO.addMedia(mediaBuilder.build());
            docDTO.addMediaType(mediaType);
            mediaIS.close();

          } catch (IOException ex) {
            logger.error(ex.toString());
          }
        } else {
          logger.error("File path in BWmeta, but not in archive: " + location);
        }
      }
    }
  }