Golang File Storage
server via HTTP (by Flume Cloud Services)
docker run -d -p 8080:8080 flumecloudservices/file-storage
mkdir $GOPATH/src/github.com/flume-cloud-services && cd $GOPATH/src/github.com/flume-cloud-services
git clone https://github.com/flume-cloud-services/file-storage.git && cd file-storage
go get -d -v
go install -v
FLUME_FILE_STORAGE_ADMIN=admin_name FLUME_FILE_STORAGE_SECRET=secret_token file-storage
Use the signin
route with the following body to generate the JWT token :
POST /signin
Body:
- name: The admin name given in FLUME_FILE_STORAGE_ADMIN by default it's simply "admin"
Return:
- If success :
- A JWT Token
- The cookie with the previously generated JWT Token
- If failed :
- Unauthorized Status
- Bad request Status
Check if the jwt is correctly generated by visiting welcome
route :
GET /welcome
Return:
- If success :
- Welcome to you visitor !
- If failed :
- Unauthorized Status
Then upload a file using the post
route with multipart encoded data :
POST /post
Body:
- file: The file to upload
- need_auth: set to "yes" if the user has to bee authenticated to access the file, otherwise sset to "no"
Return:
- If success:
- The file name which you can use to access the file
- If failed:
- Internal Server Error Status
If you want to access a private file (need authentication) use /private/<filename>
(ensure that you are signed in).
Otherwise if you want to access a public file (doesn't need authentication) use public/<filename>
.