diff --git a/pom.xml b/pom.xml
index 734c10a..c73ed3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,6 @@
-
jcustovic
Jan Čustović
@@ -32,104 +31,104 @@
Paolo Di Tommaso
paolo.ditommaso@gmail.com
-
- sbeimin
- Syte Beimin
+
+ sbeimin
+ Syte Beimin
syte.beimin@gmail.com
-
-
- jarnaiz
- Javier Arnáiz
+
+
+ jarnaiz
+ Javier Arnáiz
arnaix@gmail.com
-
-
- martint
- Martin Traverso
-
-
+
+
+ martint
+ Martin Traverso
+
+
-
- scm:git:git://github.com/Upplication/Amazon-S3-FileSystem-NIO2.git
- scm:git:git@github.com:upplication/Amazon-S3-FileSystem-NIO2.git
- https://github.com/Upplication/Amazon-S3-FileSystem-NIO2
-
+
+ scm:git:git://github.com/Upplication/Amazon-S3-FileSystem-NIO2.git
+ scm:git:git@github.com:upplication/Amazon-S3-FileSystem-NIO2.git
+ https://github.com/Upplication/Amazon-S3-FileSystem-NIO2
+
-
- UTF-8
+
+ UTF-8
2.7.1
1.7.5
1.11.232
18.0
1.5
1.3.9
-
+
-
-
- com.amazonaws
- aws-java-sdk-s3
- ${com.amazonaws.aws-java-sdk-s3.version}
-
-
- commons-logging
- commons-logging
-
-
-
-
- com.google.guava
- guava
- ${com.google.guava.guava.version}
-
+
+
+ com.amazonaws
+ aws-java-sdk-s3
+ ${com.amazonaws.aws-java-sdk-s3.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ com.google.guava
+ guava
+ ${com.google.guava.guava.version}
+
org.apache.tika
tika-core
${org.apache.tika.tika-core.version}
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- org.slf4j
- jcl-over-slf4j
- ${slf4j.version}
-
-
- com.google.code.findbugs
- jsr305
- ${com.google.code.findbugs.jsr305.version}
-
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${slf4j.version}
+
+
+ com.google.code.findbugs
+ jsr305
+ ${com.google.code.findbugs.jsr305.version}
+
-
-
- junit
- junit
- 4.11
- test
-
+
+
+ junit
+ junit
+ 4.11
+ test
+
-
- log4j
- log4j
- 1.2.17
- test
-
+
+ log4j
+ log4j
+ 1.2.17
+ test
+
-
- org.slf4j
- slf4j-log4j12
- ${slf4j.version}
- test
-
+
+ org.slf4j
+ slf4j-log4j12
+ ${slf4j.version}
+ test
+
-
- com.github.marschall
- zipfilesystem-standalone
- 1.0.1
- test
-
+
+ com.github.marschall
+ zipfilesystem-standalone
+ 1.0.1
+ test
+
com.github.marschall
@@ -139,72 +138,72 @@
-
-
- org.mockito
- mockito-core
- 1.9.5
- test
-
-
+
+
+ org.mockito
+ mockito-core
+ 1.9.5
+ test
+
+
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.3.1
-
- 1.7
- 1.7
- UTF-8
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.1
+
+ 1.7
+ 1.7
+ UTF-8
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
${maven.surfire.plugin.version}
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.1.2
-
- true
-
-
-
- create-source-jar
-
- jar-no-fork
-
-
-
-
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.1.2
+
+ true
+
+
+
+ create-source-jar
+
+ jar-no-fork
+
+
+
+
-
- org.apache.maven.plugins
- maven-release-plugin
- 2.2.1
-
- forked-path
- false
- true
- @{project.version}
-
-
-
- org.apache.maven.plugins
- maven-eclipse-plugin
- 2.9
-
- true
- false
-
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.2.1
+
+ forked-path
+ false
+ true
+ @{project.version}
+
+
+
+ org.apache.maven.plugins
+ maven-eclipse-plugin
+ 2.9
+
+ true
+ false
+
+
+
+
+
integration-tests
@@ -214,80 +213,80 @@
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- ${jacoco.agent.arg}
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 2.7.1
-
-
- **/*IT.java
-
- ${jacoco.agent.arg}
-
-
-
- integration-test
- integration-test
-
- integration-test
-
-
-
- verify
- verify
-
- verify
-
-
-
-
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ ${jacoco.agent.arg}
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.7.1
+
+
+ **/*IT.java
+
+ ${jacoco.agent.arg}
+
+
+
+ integration-test
+ integration-test
+
+ integration-test
+
+
+
+ verify
+ verify
+
+ verify
+
+
+
+
-
- org.eluder.coveralls
- coveralls-maven-plugin
- 4.1.0
-
+
+ org.eluder.coveralls
+ coveralls-maven-plugin
+ 4.1.0
+
-
- org.jacoco
- jacoco-maven-plugin
- 0.7.6.201602180812
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.7.6.201602180812
-
-
-
- pre-unit-test
-
- prepare-agent
-
-
- jacoco.agent.arg
- true
-
-
-
-
- post-unit-test
- integration-test
-
- report
-
-
-
-
-
+
+
+
+ pre-unit-test
+
+ prepare-agent
+
+
+ jacoco.agent.arg
+ true
+
+
+
+
+ post-unit-test
+ integration-test
+
+ report
+
+
+
+
+
-
- release-sign-artifacts
+
+ release-sign-artifacts
@@ -300,8 +299,8 @@
-
-
+
+
org.apache.maven.plugins
maven-javadoc-plugin
@@ -315,23 +314,23 @@
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.1
-
-
- sign-artifacts
- verify
-
- sign
-
-
- true
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.1
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+ true
+
+
+
+
org.sonatype.plugins
@@ -344,9 +343,9 @@
true
-
-
-
-
+
+
+
+
diff --git a/src/main/java/com/upplication/s3fs/util/FileTypeDetector.java b/src/main/java/com/upplication/s3fs/util/FileTypeDetector.java
new file mode 100644
index 0000000..5cf5c88
--- /dev/null
+++ b/src/main/java/com/upplication/s3fs/util/FileTypeDetector.java
@@ -0,0 +1,28 @@
+package com.upplication.s3fs.util;
+
+import org.apache.tika.Tika;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+
+public class FileTypeDetector extends java.nio.file.spi.FileTypeDetector {
+ private Tika tika;
+
+ public FileTypeDetector(Tika tika) {
+ this.tika = tika;
+ }
+
+ public FileTypeDetector() {
+ this.tika = new Tika();
+ }
+
+ @Override
+ public String probeContentType(Path path) throws IOException {
+ try (InputStream stream = Files.newInputStream(path)) {
+ return tika.detect(stream, path.getFileName().toString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/upplication/s3fs/util/FileTypeDetectorDiscoveryTest.java b/src/test/java/com/upplication/s3fs/util/FileTypeDetectorDiscoveryTest.java
new file mode 100644
index 0000000..5661596
--- /dev/null
+++ b/src/test/java/com/upplication/s3fs/util/FileTypeDetectorDiscoveryTest.java
@@ -0,0 +1,34 @@
+package com.upplication.s3fs.util;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class FileTypeDetectorDiscoveryTest {
+
+ @Test
+ public void testFileDetectorDiscovery() throws IOException, URISyntaxException {
+
+ URL resource = getClass().getClassLoader().getResource("log4j.properties");
+
+ assertNotNull(resource);
+
+ Path path = Paths.get(resource.toURI());
+ assertTrue(Files.exists(path));
+
+ String s = Files.probeContentType(path);
+ assertEquals("text/plain", s);
+ System.out.println();
+
+ }
+
+}