我是一个初学者,试图在IPFS网络上上传和访问数据。我正在跟随同一教程。这是他们网站上的代码。
# upload
import requests
import json
files = {
'fileOne': ('Congrats! This is the first sentence'),
}
response = requests.post('https://ipfs.infura.io:5001/api/v0/add', files=files)
p = response.json()
hash = p['Hash']
print(hash)
# retreive
params = (
('arg', hash),
)
response_two = requests.post('https://ipfs.infura.io:5001/api/v0/block/get', params=params)
print(response_two.text)
我尝试了一下,它可以正常工作。但是,与其只包含像这样1条记录的1个文件不同-
files = {
'fileOne': ('Congrats! This is the first sentence'),
}
我想上传多个类似的文件,例如包含多行数据的员工详情。我已经尝试了多种方法但都没有成功。请问有人能告诉我如何做吗?谢谢。
files
字典添加需要添加到IPFS的文件来扩展它。但是请注意,对于较大的文件,您可能需要逐块读取原始文件并流式传输请求。 - McSinyx