override def getPreviewType()

in backend/app/services/previewing/PreviewService.scala [31:55]


  override def getPreviewType(uri: Uri): Attempt[String] = index.getResource(uri, highlightTextQuery = None).flatMap {
    case d: Document =>
      // Check and see if we already have a preview generated. This might be the case even if the blob can be
      // passed directly to the client (eg ImageOcrExtractor rendering a PDF of the image with selectable text)
      previewStorage.getMetadata(uri.toStoragePath).map(_.mimeType).toAttempt.recoverWith {
        case _: NotFoundFailure =>
          // Can we preview this type of document at all?
          PreviewService.previewStatus(d.mimeTypes) match {
            case PreviewStatus.PassThrough if d.mimeTypes.nonEmpty =>
              // The client can render it natively
              Attempt.Right(d.mimeTypes.head)
            case PreviewStatus.PdfGenerated =>
              // We can convert this file to a PDF to preview
              Attempt.Right("application/pdf")
            case _ =>
              Attempt.Left(PreviewNotSupportedFailure)
          }
      }

    case e: Email =>
      e.html match {
        case Some(_) => Attempt.Right("application/pdf")
        case _ => Attempt.Left(PreviewNotSupportedFailure)
      }
  }