fileserver

package module
v0.0.0-...-c1fa50f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 11 Imported by: 0

README

go-fileserver

A simple HTTP server to share files over WiFi via QRCode

Installation

  • You can download compressed version from releases

    wget https://github.com/prdpx7/go-fileserver/releases/download/v0.1/fs-server-2020.07.25.tar.gz
    tar -xzf fs-server-2020.07.25.tar.gz
    chmod +x fs-server && sudo cp fs-server /usr/local/bin/fs-server
    
  • Or download the binary directly

    wget https://github.com/prdpx7/go-fileserver/releases/download/v0.1/fs-server
    chmod +x fs-server && sudo cp fs-server /usr/local/bin/fs-server
    
  • Or you can clone from GitHub and build the binary yourself

    git clone https://github.com/prdpx7/go-fileserver --depth=1
    cd go-fileserver/fs-server
    # requires go 1.14
    go build
    # make binary executable
    chmod +x ./fs-server
    # may require root permission
    cp fs-server /usr/local/bin/fs-server
    

Usage

fs-server - A simple HTTP Server to share files on a network.
Usage: fs-server [OPTIONS] <dir-path>
Options:
	-h | --help - show this message
Example:
fs-server - serve files from current directory
fs-server /home/user/documents/ - serve files from given directory

Demo

Step 1 - Run in terminal
Step 2 - Scan QRCode on Phone

Inspiration

License

  • MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomFileServer

func CustomFileServer(root http.FileSystem) http.Handler

CustomFileServer ...

func ListDirectory

func ListDirectory(w http.ResponseWriter, r *http.Request, f http.File, templateName string)

ListDirectory render directory content in templateName.html

func RequestLogger

func RequestLogger(handler http.Handler) http.Handler

RequestLogger ...

func ServeFile

func ServeFile(w http.ResponseWriter, r *http.Request, fs http.FileSystem, name string, redirect bool, templateName string)

ServeFile ...

Types

type DirectoryContent

type DirectoryContent struct {
	DirName string
	Files   []FileContent
	IPAddr  string
}

DirectoryContent to be used in rendering Index Page

type FileContent

type FileContent struct {
	Name      string
	Size      string
	URL       url.URL
	Extension string
}

FileContent ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL