An ipfs file management
request:
POST
http://localhost:9086/${userKey}/upload
http://localhost:9086/75ec6c73f3580fbb3dc8dff2353a011d/upload
response:
{
"hash": "QmYiHTWNPg2uA8HCGweVsPXPwA1UM5bSzR5rV9LHrcaaej",
"path": "QmYiHTWNPg2uA8HCGweVsPXPwA1UM5bSzR5rV9LHrcaaej",
"size": 466788,
"fileId": "d9b07510-cd1c-4c7c-9a66-33e185d3ff62"
}
A public file can be download by any user
request:
POST
http://localhost:9086/${userKey}/upload?isPublic=true
http://localhost:9086/75ec6c73f3580fbb3dc8dff2353a011d/upload?isPublic=true
response:
{
"hash": "QmYiHTWNPg2uA8HCGweVsPXPwA1UM5bSzR5rV9LHrcaaej",
"path": "QmYiHTWNPg2uA8HCGweVsPXPwA1UM5bSzR5rV9LHrcaaej",
"size": 466788,
"fileId": "d9b07510-cd1c-4c7c-9a66-33e185d3ff62"
}
request:
GET
http://localhost:9086/${userKey}/download/${fileid}
http://localhost:9086/75ec6c73f3580fbb3dc8dff2353a011d/download/d9b07510-cd1c-4c7c-9a66-33e185d3ff62
``
response:
200
file content
400
Error decrypting message: Session key decryption failed.
request:
GET
http://localhost:9086/${userKey}/grant/${fileid}/${grantToUserKey}
http://localhost:9086/75ec6c73f3580fbb3dc8dff2353a011d/grant/d9b07510-cd1c-4c7c-9a66-33e185d3ff62/a03d51bd7f225c03e47d176e362db56c
response:
200
true
400
Unauthorized
400
File not found
400
File is public
Granted user can download the file via download url
http://localhost:9086/a03d51bd7f225c03e47d176e362db56c/download/d9b07510-cd1c-4c7c-9a66-33e185d3ff62
request:
GET
http://localhost:9086/${userKey}/revoke/${fileid}/${revokeFromUserKey}
http://localhost:9086/75ec6c73f3580fbb3dc8dff2353a011d/revoke/d9b07510-cd1c-4c7c-9a66-33e185d3ff62/a03d51bd7f225c03e47d176e362db56c
response:
200
true
400
Unauthorized
400
File not found
400
File is public
Revoked user cannot download the file via download url
http://localhost:9086/a03d51bd7f225c03e47d176e362db56c/download/d9b07510-cd1c-4c7c-9a66-33e185d3ff62
request:
GET
http://localhost:9086/${userKey}/uploaded
http://localhost:9086/75ec6c73f3580fbb3dc8dff2353a011d/uploaded
response:
200
[
{
"id": "d9b07510-cd1c-4c7c-9a66-33e185d3ff62"
}
]
request:
GET
http://localhost:9086/${userKey}/permissioned
http://localhost:9086/a03d51bd7f225c03e47d176e362db56c/permissioned
response:
200
[
{
"id": "d9b07510-cd1c-4c7c-9a66-33e185d3ff62"
}
]
create a .env
file, see .env.sample
mkdir pg_data # storing data files for postgres
docker-compose up # start db and ipfs nodes
Note:
pgAdminweb ui: http://localhost:9087 username:
[email protected]
password:password
open http://localhost:9086/uploadfile.html
in browser to start uploading a file
- Change MongoDB to PostgreSql
- Producer submit a file https://github.com/ipfs/js-ipfs-api
- Consumer subscribe a file
- Producer remove a file
- Producer update a file
- Producer revoke consumer
- Consumer unsubscribe a file
- Able to PIN / UNPIN ipfs file
- Manageable folder structure
- Support API key for security