sgfs

🚀Simple http file server. A open source file server, implement by golang that can be used to upload and download files. Simple to deploy, simple to use. 中文介绍:

Stars
52

SGFS

Simple Golang File Server

SGFS, a open source file server, implement by golang that can be used to upload and download files. Simple to deploy, simple to use.

Advantage

  • SGFS is easy to configure and deploy. (use yaml config and have no runtime dependencies)

  • SGFS is easy to start and stop. (use ./startup.sh to start and use ./shutdown.sh to stop)

  • SGFS is easy to use. (use HTTP to upload and delete file)

  • SGFS use fasthttp to implement. (strong ability to deal with concurrent problems and fast speed. [https://github.com/valyala/fasthttp])

Quick Start

PS: Note that the default file operation port is 9001, and the default file access port is 9002, which is different.

HTTP

Upload file

Url : "http://127.0.0.1:9001/upload-file" Method : "http + post + multipart/form-data"

Request

key value
file upload file
uploadSubPath file save pathlike pic
token operation_tokenlike 654321

Response

{
    "code": 1,
    "message": "Save file success.",
    "data": "/pic/2019-02-22/20190222151902_7848902316.jpg"
}

code = 1 means success code != 1 means fail


Delete file

Url : "http://127.0.0.1:9001/delete-file" Method : "http + post + multipart/form-data"

Request

key value
fileUrl like "/pic/2019-02-22/20190222151902_7848902316.jpg"
token operation_tokenlike "654321"

Response

{
    "code": 1,
    "message": "Delete file success.",
    "data": null
}

code = 1 means success code != 1 means fail

About Update

When you want to update the sgfs, please note the following points.

  1. Do not delete upload folder because it saved files.
  2. If you modify the conf.yml about old version please backup it before update.
  3. Download release version and decompression to update. Easy.

TODO

  • remove startup and shutdown scripts
  • add cli commands to start server and shutdown
  • code cleanup
  • add unit tests
Package Rankings
Top 8.17% on Proxy.golang.org