A http download and upload server
- Default to truncate if file exist
- Delete support
- Truncate support
- Form value upload
- File upload ( no need extra static index page anymore )
- Any level path specify
- Web Any path upload support
go get github.com/chinglinwen/fileserver2
[~ t1 ] $ cat example.log
example body
[~ t1 ] $ curl localhost:8000/uploadapi -F [email protected]
Files uploaded successfully : example.log 13 bytes
Results
[~ t ] $ cat example.log
example body
[~ t1 ] $ curl localhost:8000/uploadapi -F file=test -F data="test body"
Files uploaded successfully : test 9 bytes
[~ t1 ] $ curl localhost:8000/uploadapi -F file="a/b/c" -F data="hello"
Files uploaded successfully : a/b/c 5 bytes
[~ t1 ] $ curl localhost:8000/uploadapi -F file="a/b/c" -F [email protected]
Files uploaded successfully : a/b/c 3 bytes
[~ t1 ] $ curl localhost:8000/uploadapi -F file="../a/b/c" -F [email protected]
file path should not contain the two dot
or
[~ t1 ] $ curl localhost:8000/a/b/uploadapi -F file="c" -F data="hello"
Files uploaded successfully : a/b/c 5 bytes
[~ t1 ] $ curl localhost:8000/a/b/uploadapi -F file="c" -F [email protected]
Files uploaded successfully : a/b/c 3 bytes
[~ t1 ] $ curl localhost:8000/../a/b/uploadapi -F file="c" -F [email protected] # won't work
[~ t1 ] $ curl localhost:8000/uploadapi -F file=example.log -F delete=yes
file: example.log deleted
[~ t1 ] $ curl localhost:8000/uploadapi -F file="a/b/c" -F delete=yes
file: a/b/c deleted
[~ t1 ] $ curl localhost:8000/uploadapi -F file="a" -F delete=yes
file: a deleted
if file not exist, it will create the file
if file exist, by default it will append to the file
use truncate to overwrite the file
curl localhost:8000/uploadapi -F [email protected] -F truncate=yes
or
curl localhost:8000/uploadapi -F file=test -F data="test body" -F truncate=yes
$ fileserver2 -h
Usage of fileserver2:
-author
Show author.
-path string
File server path. (default ".")
-port string
Port number. (default "8000")
-v Show version.
Notes: path specify where the file will be stored
[~ t1 ] $ wget "localhost:8000/Track 1.wav"
--2016-06-23 11:43:18-- http://localhost:8000/Track%201.wav
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26869360 (26M) [audio/x-wav]
Saving to: `Track 1.wav'
100%[=============================================================================>] 26,869,360 --.-K/s in 0.1s
2016-06-23 11:43:18 (240 MB/s) - `Track 1.wav' saved [26869360/26869360]
[~ t1 ] $
register
./reg.sh
deregister
./dereg.sh
end