Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prusnak/ipfsstorage
https://github.com/prusnak/ipfsstorage
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/prusnak/ipfsstorage
- Owner: prusnak
- Created: 2016-02-23T18:12:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-23T18:21:20.000Z (almost 9 years ago)
- Last Synced: 2024-12-16T16:06:03.564Z (25 days ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ipfsStorage
===========Simple localStorage-like storage using IPFS.
Usage
-----```
> ipfsStorage
< Object {}> ipfsStorage.num = 23
< 23> ipfsStorage.text = 'test'
< "test"> ipfsStorage
< Object {num: 23, text: "test"}> ipfsStorage.save()
< Save successful: QmcuopysRiM4cuA9YkGpwZoTER3JwK6rY2oE6a8ua51cyf
```Reload page with F5 to clear ipfsStorage.
```
> ipfsStorage
< Object {}> ipfsStorage.load('QmcuopysRiM4cuA9YkGpwZoTER3JwK6rY2oE6a8ua51cyf')
< Load successful: QmcuopysRiM4cuA9YkGpwZoTER3JwK6rY2oE6a8ua51cyf> ipfsStorage
< Object {num: 23, text: "test"}
```Functions `load()` and `save()` return promises which return object data and object hash respectively.
IPFS Gateway Setup
------------------In order for this to work you need to add the following to your IPFS config file:
``` json
"Gateway": {
"HTTPHeaders": {
"Access-Control-Allow-Credentials": [
"true"
],
"Access-Control-Allow-Methods": [
"PUT",
"GET",
"POST",
"OPTIONS"
],
"Access-Control-Expose-Headers": [
"Ipfs-Hash"
],
"Access-Control-Allow-Origin": [
"*"
]
},
"RootRedirect": "",
"Writable": true
},
```