Hashed content delivery. HashCD delivers content by its SHA256 hash. This way the same file is never stored more than once.
Replace URI scheme, localhost, port if needed. Localhost is used to simplify developing by copying the curl commands.
Create a new file if it doesn't exist yet
curl --location --request POST 'http://localhost:8080/u' --form 'f=@"/tmp/my_file"
If the file didn't exist yet
Status 201 Created
{"hash": "<hash of the created file>"}
If the file already existed
Status 200 OK
{"hash": "<hash of the file>"}
Download a file by its hash. The hash is extracted from everything in hashish.
All these requests fetch the same file:
/d/13663375de6965ba08f3e898612630088500f3ee4f6104bdc9ddf7ce70056437
/d/logo_13663375de6965ba08f3e898612630088500f3ee4f6104bdc9ddf7ce70056437.jpg
/d/logo.jpg?t=13663375de6965ba08f3e898612630088500f3ee4f6104bdc9ddf7ce70056437
/d/logo.jpg?myhashkey=13663375de6965ba08f3e898612630088500f3ee4f6104bdc9ddf7ce70056437
curl --location --request GET 'http://localhost:8080/d/<hash of the file>
If the file is found
Status 200 OK
Header | Values |
---|---|
Content-Length | Length of the file in bytes |
Content-Type | Media type of the file, e.g. application/pdf |
X-Served-From | disk on server or cache on server |
If the file is not found
Status 404 Not Found
Retrieve a list of available files
Status 200 OK
[
{
"hash": "<hash of a file>",
"size": <length of the file in bytes>
},
{
"hash": "<hash of a file>",
"size": <length of the file in bytes>
},
]
Backend: go run .
Frontend: cd frontend && yarn start
- Build frontend
cd frontend && yarn build
- Run
./deploy.sh