urlv/http-file-server


Java asynchronous http file server

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.urlv:http-file-server:2.0.0'
	}
	dependencies {
		implementation("com.github.urlv:http-file-server:2.0.0")
	}
	<dependency>
	    <groupId>com.github.urlv</groupId>
	    <artifactId>http-file-server</artifactId>
	    <version>2.0.0</version>
	</dependency>

                            
    libraryDependencies += "com.github.urlv" % "http-file-server" % "2.0.0"
        
        

                            
    :dependencies [[com.github.urlv/http-file-server "2.0.0"]]
        
        

Readme


http-file-server

Java asynchronous http file server

Efficient. Secured. Robust. Asynchronous. Single Threaded. Easy to use.

Example

Running a server on port 8823 And makes the files in C:\\data\\images folder accessible

HttpFileServer server = new HttpFileServer(8823, "C:\\data\\images");
server.start(); // it's async, so it running the server and continues to the next line
System.out.println("server is up");

Now open a browser and go to http://127.0.0.1:8823/yourface.jpg (or any other file found there including subfolders)<br> And as you can see, the file is in front of you via HTTP.

use server.close() to close the server.

<br>

Using Maven

Set up this repository in your pom.xml

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

And add this dependency

<dependencies>
  <dependency>
    <groupId>com.github.urlv</groupId>
    <artifactId>http-file-server</artifactId>
    <version>2.0.0</version>
  </dependency>
</dependencies>

Good Luck ;