Name: IPFS-Store
Owner: ConsenSys
Description: IPFS Storage service with search capability
Created: 2018-02-15 17:51:49.0
Updated: 2018-02-18 01:42:29.0
Pushed: 2018-02-16 20:37:09.0
Homepage: null
Size: 43
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
IPFS-Store aims is to provide an easy to use IPFS storage service with search capability for your project.
The service is composed of three main components:
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
After checking out the code, navigate to the root directory
/path/to/ipfs-store/ipfs-store-service/
Compile, test and package the project
n clean package
Run the project
a. If you have a running instance of IPFS and ElasticSearch
Executable JAR:
port IPFS_HOST=localhost
port IPFS_PORT=5001
port ELASTIC_CLUSTERNODES=localhost:9300
port ELASTIC_CLUSTERNAME=elasticsearch
va -jar target/ipfs-store.jar
Docker:
cker build . -t kauri/ipfs-store:latest
port IPFS_HOST=localhost
port IPFS_PORT=5001
port ELASTIC_CLUSTERNODES=localhost:9300
port ELASTIC_CLUSTERNAME=elasticsearch
cker run -p 8040:8040 kauri/ipfs-store
b. If you prefer build all-in-one with docker-compose
cker-compose -f docker-compose.yml build
cker-compose -f docker-compose.yml up
| Operation | Description | Method | URI | | ——– | ——– | ——– | ——– | | store | Store content into IPFS |POST | /ipfs-store/store | | index | Index content |POST | /ipfs-store/index | | store_index | Store & Index content | POST | /ipfs-store/store_index | | fetch | Get content | GET | /ipfs-store/fetch/{index}/{hash} | | search | Search content | POST | /ipfs-store/search/{index} | | search | Search content | GET | /ipfs-store/search/{index} |
Store a content (any type) in IPFS
URL: /ipfs-store/store
Method: POST
Header: N/A
URL Params: N/A
Data Params:
file: [content]
Sample Request:
rl -X POST \
p://localhost:8040/ipfs-store/store' \
file=@/home/gjeanmart/hello.pdf'
Success Response:
h": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o"
Index IPFS content into the search engine
/ipfs-store/index
POST
| Key | Value | | ——– | ——– | | content-type | application/json |
URL Params N/A
Data Params
request:
| Name | Type | Mandatory | Default | Description | | ——– | ——– | ——– | ——– | ——– | | index | String | yes | | Index name | | id | String | no | | Identifier of the document in the index. id null, autogenerated | | content_type | String | no | | Content type (MIMETYPE) | | hash | String | yes | | IPFS Hash of the content | | index_fields | Key/Value[] | no | | Key/value map presenting IPFS content metadata|
ndex": "documents",
d": "hello_doc",
ontent_type": "application/pdf",
ash": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o",
ndex_fields": [
{
"name": "title",
"value": "Hello Doc"
},
{
"name": "author",
"value": "Gregoire Jeanmart"
},
{
"name": "votes",
"value": 10
},
{
"name": "date_created",
"value": 1518700549
}
-X POST \
'http://localhost:8040/ipfs-store/index' \
-H 'content-type: application/json' \
-d '{"index":"documents","id":"hello_doc","content_type":"application/pdf","hash":"QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o","index_fields":[{"name":"title","value":"Hello Doc"},{"name":"author","value":"Gregoire Jeanmart"},{"name":"votes","value":10},{"name":"date_created","value":1518700549}]}'
Success Response:
ex": "documents",
: "hello_doc",
h": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o"
Store content in IPFS and index it into the search engine
URL /ipfs-store/store_index
Method: POST
Header: N/A
URL Params N/A
Data Params
file: [content]
request:
| Name | Type | Mandatory | Default | Description | | ——– | ——– | ——– | ——– | ——– | | index | String | yes | | Index name | | id | String | no | | Identifier of the document in the index. id null, autogenerated | | content_type | String | no | | Content type (MIMETYPE) | | hash | String | yes | | IPFS Hash of the content | | index_fields | Key/Value[] | no | | Key/value map presenting IPFS content metadata|
ndex": "documents",
d": "hello_doc",
ontent_type": "application/pdf",
ash": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o",
ndex_fields": [
{
"name": "title",
"value": "Hello Doc"
},
{
"name": "author",
"value": "Gregoire Jeanmart"
},
{
"name": "votes",
"value": 10
},
{
"name": "date_created",
"value": 1518700549
}
-X POST \
tp://localhost:8040/ipfs-store/store_index \
'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
file=@/home/gjeanmart/hello.pdf \
'request={"index":"documents","id":"hello_doc","content_type":"application/pdf","hash":"QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o","index_fields":[{"name":"title","value":"Hello Doc"},{"name":"author","value":"Gregoire Jeanmart"},{"name":"votes","value":10},{"name":"date_created","value":1518700549}]}'
Success Response:
ex": "documents",
: "hello_doc",
h": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o"
Get content on IPFS by hash
URL http://localhost:8040/ipfs-store/fetch/{index}/{hash}
Method: GET
Header: N/A
URL Params N/A
Sample Request:
rl \
'http://localhost:8040/ipfs-store/fetch/documents/QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o' \
-o hello_doc.pdf
Success Response:
Search content accross an index using a dedicated query language
http://localhost:8040/ipfs-store/search/{index}
GET
or POST
| Key | Value | | ——– | ——– | | content-type | application/json |
| Name | Type | Mandatory | Default | Description | | ——– | ——– | ——– | ——– | ——– | | pageNo | Int | no | 1 | Page Number | | pageSize | Int | no | 20 | Page Size / Limit | | sort | String | no | | Sorting attribute | | dir | ASC/DESC | no | ASC | Sorting direction | | query | String | no | | Query URL encoded (for GET call) |
The search
operation allows to run a multi-criteria search against an index. The body combines a list of filters :
| Name | Type | Description | | ——– | ——– | ——– | | name | String | Index field to perform the search | | names | String[] | Index fields to perform the search | | operation | See below | Operation to run against the index field | | value | Any | Value to compare with |
| Operation | Description | | ——– | ——– | | full_text | Full text search | | equals | Equals | | not_equals | Not equals | | contains | Contains the word/phrase | | in | in the following list | | gt | Greater than | | gte | Greater than or Equals | | lt | Less than | | lte | Less than or Equals |
uery": [
{
"name": "title",
"operation": "contains",
"value": "Hello"
},
{
"names": ["author", "title"],
"operation": "full_text",
"value": "Gregoire"
},
{
"name": "votes",
"operation": "lt",
"value": "5"
}
-X POST \
'http://localhost:8040/ipfs-store/search/documents' \
-H 'content-type: application/json' \
-d '{"query":[{"name":"title","operation":"contains","value":"Hello"},{"name":"author","operation":"equals","value":"Gregoire Jeanmart"},{"name":"votes","operation":"lt","value":"5"}]}'
-X GET \
ttp://localhost:8040/ipfs-store/search/documents?page=1&size=2&query=%7B%22query%22%3A%5B%7B%22name%22%3A%22votes%22%2C%22operation%22%3A%22lt%22%2C%22value%22%3A%225%22%7D%5D%7D' \
'Accept: application/json' \
'Content-Type: application/json' \
Success Response:
ontent": [
{
"index": "documents",
"id": "hello_doc",
"hash": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o",
"content_type": "application/pdf",
"index_fields": [
{
"name": "__content_type",
"value": "application/pdf"
},
{
"name": "__hash",
"value": "QmWPCRv8jBfr9sDjKuB5sxpVzXhMycZzwqxifrZZdQ6K9o"
},
{
"name": "title",
"value": "Hello Doc"
},
{
"name": "author",
"value": "Gregoire Jeanmart"
},
{
"name": "votes",
"value": 10
},
{
"name": "date_created",
"value": 1518700549
}
]
}
t": null,
stPage": false,
alElements": 4,
tPage": true,
alPages": 1,
berOfElements": 4,
e": 20,
ber": 1