-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c1b665
commit 46f7b98
Showing
20 changed files
with
1,180 additions
and
759 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Files demo browser - web3.storage | ||
|
||
🚧 **WORK IN PROGRESS** 🚧 | ||
|
||
A demo using web3.storage client in the browser to pre-calculate the CID for an asset then storing it on tbd.storage and confirming that it uses the exact same CID for the asset. | ||
|
||
## Getting started | ||
|
||
```console | ||
npm install | ||
npm run dev | ||
|
||
# or | ||
yarn | ||
yarn dev | ||
``` | ||
|
||
Then visit `http://localhost:3000?key=<your web3.storage API KEY here>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>CAR upload - nft.storage</title> | ||
</head> | ||
<body> | ||
<pre id="out"></pre> | ||
<script type="module" src="/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Web3Storage } from 'web3.storage' | ||
import { Web3File } from 'web3-file' | ||
|
||
const endpoint = 'https://api.web3.storage' // the default | ||
const token = | ||
new URLSearchParams(window.location.search).get('key') || 'API_KEY' // your API key from https://web3.storage/manage | ||
|
||
async function main() { | ||
const storage = new Web3Storage({ endpoint, token }) | ||
|
||
const files = prepareFiles() | ||
|
||
// send the files to tbd.storage | ||
const cid = await storage.put(files) | ||
|
||
// TODO | ||
console.log('added', cid) | ||
// check that the CID is pinned | ||
// const status = await store.status(cid) | ||
// log(status) | ||
} | ||
|
||
function prepareFiles () { | ||
const data = 'Hello web3.storage!' | ||
const data2 = 'Hello web3.storage!!' | ||
|
||
return [ | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data), | ||
'data.zip', | ||
{ path: '/dir/data.zip' } | ||
), | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data2), | ||
'data2.zip', | ||
{ path: '/dir/data2.zip' } | ||
), | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data), | ||
'data.zip', | ||
{ path: '/dir/dir/data.zip' } | ||
), | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data2), | ||
'data2.zip', | ||
{ path: '/dir/dir/data2.zip' } | ||
) | ||
] | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"vite": "^2.3.7" | ||
}, | ||
"dependencies": { | ||
"web3.storage": "../../" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Files demo Node.js - web3.storage | ||
|
||
🚧 **WORK IN PROGRESS** 🚧 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Web3Storage } from '../../src/lib.js' | ||
import { Web3File } from 'web3-file' | ||
|
||
// TODO | ||
const endpoint = 'https://api.web3.storage' // the default | ||
const token = 'API_KEY' // your API key from https://web3.storage/manage | ||
|
||
async function main() { | ||
const storage = new Web3Storage({ endpoint, token }) | ||
|
||
const files = prepareFiles() | ||
const cid = await storage.put(files) | ||
|
||
console.log('added', cid) | ||
} | ||
|
||
// TODO: Read a fixstures folder instead | ||
function prepareFiles () { | ||
const data = 'Hello web3.storage!' | ||
const data2 = 'Hello web3.storage!!' | ||
|
||
return [ | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data), | ||
'data.zip', | ||
{ path: '/dir/data.zip' } | ||
), | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data2), | ||
'data2.zip', | ||
{ path: '/dir/data2.zip' } | ||
), | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data), | ||
'data.zip', | ||
{ path: '/dir/dir/data.zip' } | ||
), | ||
Web3File.fromBytes( | ||
new TextEncoder().encode(data2), | ||
'data2.zip', | ||
{ path: '/dir/dir/data2.zip' } | ||
) | ||
] | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "filecoin-storage-examples", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "Examples of using filecoin.storage in Node.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Vasco Santos", | ||
"license": "(Apache-2.0 AND MIT)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.