Validate what an IPFS gateway returns by decoding and validating the CAR block.
Usage
CARs can be read from memory or file and can be exported as a file/folder or byte stream
>>> import asyncio
>>> import aiohttp
...
>>> from ipfs_car_decoder import ChunkedMemoryByteStream, stream_bytes
...
>>> ipfs_hash = 'bafkreibm6jg3ux5qumhcn2b3flc3tyu6dmlb4xa7u5bf44yegnrjhc4yeq'
...
>>> async def test():
... stream = ChunkedMemoryByteStream()
... async with aiohttp.ClientSession() as session:
... async with session.get(f'https://ipfs.io/ipfs/{ipfs_hash}', headers={'Accept':'application/vnd.ipld.car'}) as resp:
... resp.raise_for_status()
... assert resp.content_type == 'application/vnd.ipld.car'
... async for chunk, _ in resp.content.iter_chunks():
... await stream.append_bytes(chunk)
... await stream.mark_complete()
... acc = b''
... async for chunk in stream_bytes(ipfs_hash, stream):
... acc += chunk
... print(acc)
...
>>> asyncio.run(test())
b'hello'
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ipfs_car_decoder-0.1.1.tar.gz
(11.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipfs_car_decoder-0.1.1.tar.gz.
File metadata
- Download URL: ipfs_car_decoder-0.1.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d7ae3fc519f5cdece38e229037fe1e5d6609ee8653d6baf538013c66010c41b
|
|
| MD5 |
05de8c2157cb4edc7608f76520027599
|
|
| BLAKE2b-256 |
e85e11eb9da00c2de2dac42f865ef8f513423c62fa7ed68a9801b1b6ed33adc9
|
File details
Details for the file ipfs_car_decoder-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ipfs_car_decoder-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16482061a0edcc8fa6886f2a70537541a6814dfaa4470b4b6473009c90ecbf62
|
|
| MD5 |
30b69ac2a1383fefd179dffc0d75915e
|
|
| BLAKE2b-256 |
53cead99a522e1a723a2880b2b5d64b2091e879ba15714e941541c167945656f
|