blockchain:dappsからipfsにファイルをアップロードする
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン | |||
| blockchain:dappsからipfsにファイルをアップロードする [2022/06/16 12:52] – dot | blockchain:dappsからipfsにファイルをアップロードする [2022/06/16 12:54] (現在) – dot | ||
|---|---|---|---|
| 行 31: | 行 31: | ||
| <code JavaScript> | <code JavaScript> | ||
| - | import React, { BaseSyntheticEvent, | + | import React, { useState, useEffect } from ' |
| import type { IPFS } from ' | import type { IPFS } from ' | ||
| import * as IPFSCore from ' | import * as IPFSCore from ' | ||
| 行 70: | 行 70: | ||
| setIpfsReady(Boolean(ipfs)); | setIpfsReady(Boolean(ipfs)); | ||
| }; | }; | ||
| - | const fileSelected = async (event: | + | const fileSelected = async (event: |
| if(!isIpfsReady) return; | if(!isIpfsReady) return; | ||
| - | const targetFile = event.target.files[0]; | + | const targetFile = event.target.files?.[0]; |
| - | const _result = await ipfs.add(targetFile); | + | |
| - | //const _result = await ipfs.add(' | + | |
| - | setCID(_result.path); | + | //const _result = await ipfs.add(' |
| + | setCID(_result.path); | ||
| + | } | ||
| }; | }; | ||
blockchain/dappsからipfsにファイルをアップロードする.1655383960.txt.gz · 最終更新: by dot
