- Go (1.11)
- IPFS (0.4.17)
- go-ipfs-api
- Install Go
- Install IPFS
- Get get-ipfs-api by doing:
go get -u github.com/ipfs/go-ipfs-api
- Start the IPFS daemon:
ipfs daemon
- In a new shell clone and move into this directory:
git clone https://github.com/lambdaclass/go-http-ipfs.git && go-http-ipfs
- Build and run the Go server:
go run
Now you will have the HTTP server running in port 8080.
This endpoint receives the file the user wants to upload to IPFS. The request must be a POST with a multipart form in which the field file
has the file to upload.
Example:
$> curl localhost:8000/upload -F 'file=@example.txt'
QmbZGZZFbc9eFB1hfZj8PHsp8ZrszwXgf3nkrFx8z3v6ri
This endpoint fetches a file from IPFS using its hash and returns it to the client for download. The request must be a GET where :hash
is the hash identifying the file in IPFS
Example:
curl localhost:8000/file/QmbZGZZFbc9eFB1hfZj8PHsp8ZrszwXgf3nkrFx8z3v6ri -O