Simple HTTP uploader for saving artifacts.
983
HTTP content upload service written in go. Works only as content receiver (i.e. video ingestion platform). Used as new HTTP uploader for Educast service. The following are key aspects of this service:
PUT /files/(path-to/filename)). Subfolders are created if they do not exist on server.For more information visit fccn/go-simple-upload-server github project page.
The server has no Basic/Digest authentication, instead it implements a simple "security token" authentication.
All requests should have token parameter (it can be passed from query strings or a form parameter). If it is completely matched with the server's token, the access is allowed; otherwise, returns 401 Unauthorized.
You can specify the server's token on startup by setting the APP_TOKEN environment variable. If you don't so, the server generates the token and writes it to STDOUT at WARN level log.
Before starting the server, if you want to use a volume for the uploads make sure the volume folder is owned by a user with id 1028 and gid 1000. To start the uploader running on port 25478 (HTTP) run the following command:
$ mkdir $HOME/upload&& chown -R 1028:100 $HOME/upload
$ docker run -p 25478:25478 -v $HOME/upload:/home/educast_upload/uploads -e "APP_TOKEN=<my-token>" stvfccn/http-uploader
You may also start the application using docker-compose:
version: '3.4'
services:
httpuploader:
image: stvfccn/http-uploader
volumes:
- ./uploads:/home/educast_upload/uploads
restart: always
environment:
- APP_TOKEN=<my-token>
ports:
- "25478:25478"
You can upload files with POST /upload.
The filename is taken from the original file if available. If not, SHA1 hex digest will be used as the filename.
$ echo 'Hello, world!' > sample.txt
$ curl [email protected] 'http://localhost:25478/upload?token=f9403fc5f537b4ab332d'
{"ok":true,"path":"/files/sample.txt"}
$ cat $HOME/tmp/sample.txt
hello, world!
OR
Use PUT /files/(path-to/filename).
In this case, the original file name is ignored, and the name and path to store the file (inside the uploads folder) is taken from the URL.
$ curl -X PUT [email protected] "http://localhost:25478/files/myfolder/another_sample.txt?token=f9403fc5f537b4ab332d"
{"ok":true,"path":"/files/myfolder/another_sample.txt"}
HEAD /files/(path-to/filename).
$ curl -I 'http://localhost:25478/files/myfolder/foobar.txt?token=f9403fc5f537b4ab332d'
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 9
Content-Type: text/plain; charset=utf-8
Last-Modified: Sun, 09 Oct 2016 14:35:39 GMT
Date: Sun, 09 Oct 2016 14:35:43 GMT
$ curl -I 'http://localhost:25478/files/unknown?token=f9403fc5f537b4ab332d'
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sun, 09 Oct 2016 14:37:48 GMT
Content-Length: 19
Content type
Image
Digest
Size
5.6 MB
Last updated
over 7 years ago
docker pull stvfccn/http-uploader