File Share
Live on this serverPassword protected directory listing with resumable downloads.
Directory Browsing Documentation
Range Support Documentation
GenHTTP.Modules.DirectoryBrowsing Package on NuGet
GenHTTP.Modules.IO Package on NuGet
using GenHTTP.Api.Content;
using GenHTTP.Modules.Authentication;
using GenHTTP.Modules.DirectoryBrowsing;
using GenHTTP.Modules.IO;
public static class FileShareSample
{
public static IHandlerBuilder Create()
{
/*
*
* Shares a folder with friends: they log in with their browser, browse
* through the files and download them. Downloads of large files can be
* paused and resumed, as range requests are supported.
*
* Open /samples/file-share/ and log in as "friend" / "secret".
*
* See https://genhttp.org/documentation/content/handlers/listing/
* and https://genhttp.org/documentation/content/concerns/range-support/
*
*/
// the files shipped with this website (resources/samples/files),
// use ResourceTree.FromDirectory("/srv/share") to share a directory
var files = Resources.Tree("samples/files");
var auth = BasicAuthentication.Create()
.Add("friend", "secret");
return Listing.From(files)
.AddRangeSupport()
.Authentication(auth);
}
}Try it
Send the requests to the sample running on this server - change the path, headers or body as you like, or copy them as curl commands.
Browse the files
Log in as "friend" with password "secret".
Download the first 100 bytes of a file
206 Partial Content
curl -i -H 'Authorization: Basic ZnJpZW5kOnNlY3JldA==' -H 'Range: bytes=0-99' 'https://genhttp.org/samples/file-share/README.md'