Sign inSign up

jamoyjamie/restdir

By jamoyjamie

Updated about 4 years ago

restdir is a small utility for serving a directory on HTTP, allowing upload to and download from it.

Image
0

252

jamoyjamie/restdir repository overview

restdir

restdir is a small utility for serving a directory on HTTP, allowing upload to and download from it.

It is useful for modifying contents of hard to reach file systems like Docker volumes.

The interface is plain and simple REST. Upload: PUT. Download: GET. Delete: DELETE

This is designed as a testing/dev utility and not for production use

Building

dotnet publish -r win-x64

For other runtime monikers see here.

Usage

restdir

That will serve the current directory on http://localhost:5000 (note that this only accepts requests from localhost!).

Here are some options if you want to make it more complicated:

DescriptionDefaultExample
-d, --directoryThe path to the directory to serveCurrent directory-d www/images
-p, --prefixThe prefix to serve on (see here for more info)http://localhost:5000-p http://my-domain.com:8080/images/
-r, --read-onlyServes in read only modeOff-r
-l, --log-requestsEnables request (access) loggingOff-l
--allow-recursive-deleteAllows deletion of whole directories and all their content. Yikes!Off--allow-recursive-delete

TODO

  • Docker image
  • CI/CD
  • Integation tests
  • HTTPS support
  • HEAD/OPTIONS support

Why not POST?

An age old debate indeed.

POST isn't necessarily wrong, just PUT is a better fit here because you know the file name you're uploading:

http://localhost:5000/things/thing-12

POST is much better when you're uploading something you want a name/ID to be generated for you by the server

http://localhost:5000/things/

In which case the server should be returning you that generated name/ID in a Location header in the response

Location: http://localhost:5000/things/thing-34

Tag summary

Content type

Image

Digest

sha256:63603c919

Size

66 MB

Last updated

about 4 years ago

docker pull jamoyjamie/restdir