• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

web3-storage/web3.storage: ⁂ The simple file storage service for IPFS & Fil ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

web3-storage/web3.storage

开源软件地址:

https://github.com/web3-storage/web3.storage

开源编程语言:

JavaScript 63.9%

开源软件介绍:


web3.storage

The simple file storage service for IPFS & Filecoin.

Usage

Store your files with web3.storage and retrieve them via their unique Content ID. Our tools make it simple to hash your content locally, so you can verify the service only ever stores the exact bytes you asked us to. Pick the method of using with web3.storage that works for you!

Website

Create an account via https://web3.storage and upload right from the website using our uploader. Under the hood it uses the web3.storage client that we publish to npm to chunk and hash your files to calculate the root IPFS CID in your browser before sending them to https://api.web3.storage.

Once uploaded you can fetch your data from any IPFS gateway via https://dweb.link/ipfs/<root cid>

Create an api token for your account and you can use any of the following alternatives to upload your data.

JS Client

Use npm to install the web3.storage module into your JS project, create an instance of the client with your api token, and use the .put method to upload your files in node.js or the browser.

node.js

const { Web3Storage, getFilesFromPath } = require('web3.storage')
const storage = new Web3Storage({ token: process.env.WEB3_TOKEN })
const files = await getFilesFromPath(process.env.PATH_TO_ADD)
const cid = await storage.put(files)
console.log(`IPFS CID: ${cid}`)
console.log(`Gateway URL: https://dweb.link/ipfs/${cid}`)

See https://web3.storage/docs/#quickstart for a guide to using the js client for the first time.

CLI

Our command line tool w3 is a wrapper around the JS Client to make adding files from your terminal as simple as w3 put ~/gifs.

Install @web3-storage/w3 globally and save your api token then add your files to web3! It calculates the root CID for your files locally before sending them to web3.storage.

shell

$ w3 token
? Paste your API token for api.web3.storage › <your api token here>
⁂ API token saved

$ w3 put ~/Pictures/ayy-lamo.jpg
⁂ Stored 1 file
⁂ https://dweb.link/ipfs/bafybeid6gpbsqkpfrsx6b6ywrt24je4xqe4eo4y2wldisl6sk7byny5uky

Use it anywhere you can get a shell. Get creative! For example, we use this for perfomance testing the upload speed in CI!

Run w3 --help or have a look at https://github.com/web3-storage/web3.storage/tree/main/packages/w3#readme to find out everything it can do.

GitHub Action

The Action add_to_web3 wraps the w3 CLI to let you add files to web3.storage from your GitHub Workflows.

github-workflow.yaml

- run: npm run build # e.g output your static site to `./dist`

- uses: web3-storage/add-to-web3@v2
  id: web3
  with:
    web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }}
    path_to_add: 'dist'

- run: echo ${{ steps.web3.outputs.cid }}
# "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am"
- run: echo ${{ steps.web3.outputs.url }}
# "https://dweb.link/ipfs/bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am"

Set your api token and the path_to_add and watch it fly! We use add_to_web3 to add the web3.storage website to web3.storage from CI ∞!

cURL

Want to try it out? You can POST a file smaller than 100MB straight to https://api.web3.storage/upload with cURL.

curl -X POST --data-binary @file.txt -H 'Authorization: Bearer YOUR_API_KEY' https://api.web3.storage/upload  -s | jq
{
  "cid":"bafkreid65ervf7fmfnbhyr2uqiqipufowox4tgkrw4n5cxgeyls4mha3ma"
}

See https://web3.storage/docs/ for our complete documentation


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap