# FileServer **Repository Path**: XFY9326/FileServer ## Basic Information - **Project Name**: FileServer - **Description**: Simple Http file server based on Ktor and supported basic Http auth. - **Primary Language**: Kotlin - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-10 - **Last Updated**: 2021-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FileServer Simple Http file server based on Ktor and supported basic Http auth. Might be useful if you want to share or upload simple files in terminal. Just for fun. ## Build ```shell # Only single jar # Output: build/distributions ./gradlew assembleJar # Executable script bundle # Output: build/distributions ./gradlew assemble ``` ## Usage ``` java -jar FileServer-.jar [OPTIONS] COMMAND [ARGS]... Options: -h, --help Show this message and exit Commands: launch Launch file server default-config Generate default config ``` ```shell # For more details, see help java -jar FileServer-.jar -h java -jar FileServer-.jar launch -h java -jar FileServer-.jar default-config -h ``` **Attention1: Not allow accessing hidden file or directory.** **Attention2: Not allow accessing file out of root path.** ## Check server ```shell # Should return 'Server OK!' curl http://localhost:8080 ``` ## Upload file ```shell # Upload file and create dir curl --upload-file "http://localhost:8080/f//" # Upload multiple files curl -F "=@" -F "=@" "http://localhost:8080/f//" # Basic Http auth curl -u : --upload-file "http://localhost:8080/f//" ``` ## Download file ```shell # Download file wget "http://localhost:8080/f//" curl -O "http://localhost:8080/f//" # Download multiple files wget --no-parent -r --reject "index.html*" "http://localhost:8080/f//" # Basic Http auth wget --user --password "http://localhost:8080/f//" curl -u : -O "http://localhost:8080/f//" ``` ## List file ```shell # Show file names under the in text curl "http://localhost:8080/l/" # Show file url under the in text # Param value doesn't matter curl "http://localhost:8080/l/?url=1" # Or shorter curl "http://localhost:8080/l/?u=1" # Only show files under the in text # Param value doesn't matter curl "http://localhost:8080/l/?file=1" # Or shorter curl "http://localhost:8080/l/?f=1" ``` ## Download multiple files with url list ```shell # You can use 'file' and 'url' together to download multiple files curl -s "http://localhost:8080/l/\?f\=1\&u\=1" | wget -i - ``` ## View file list in Browser Open http://localhost:8080/f/ in browser. Support list files, upload files and download file. ## Config ```shell # Generate default config file java -jar FileServer-.jar default-config # Launch with config java -jar FileServer-.jar launch --config config.json ``` Default config: ```json { "host": "0.0.0.0", "port": 8080, "root": "files", "allowAnonymous": true, "allowAnonymousDownload": true, "users": { } } ``` | Field | Description | | ----- | ----- | | host | Server host | | port | Server port | | root | File server root path | | allowAnonymous | Close basic http auth | | allowAnonymousDownload | Download without basic http auth
No effect if allowAnonymous=true
http://HOST/f/PATH/FILE | | users | UserName:String to Password:String dict
Useless if allowAnonymous=true | **Attention: Blank or empty UserNames and Passwords are not allowed to use!**