简体   繁体   中英

Java Service Provider Interface for mime-detection in Play Framework?

The Java 7 implementation of probeContentType(path) is pretty incomplete so wanted to use Apache Tika for better reliability. I found a post about how to override the probeContentType function via using the Java SPI in Maven but am not sure how to accomplish the same thing in the Play! Framework which uses sbt?

Per the link you provided, all you need is to insure that:

  1. The file src/main/resources/META-INF/services/java.nio.file.spi.FileTypeDetector exists
  2. Its contents are the fully qualified class name of your FileTypeDetector wrapper around Tika
  3. The file gets copied into the META-INF/services directory in the JAR file when it is built.

Exactly how you perform the last step will depend on how exactly you are building the jarfile. One possible starting point is https://stackoverflow.com/a/9772931/390153 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM