aleph-im / aleph-client

Lightweight Python Client library for the Aleph.im network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There is no function to download raw data from Aleph

hoh opened this issue · comments

Users should not have to write code such as this themselves:

async def download_data_from_aleph(file_hash) -> bytes:
    async with aiohttp.ClientSession(connector=aiohttp.TCPConnector()) as session:
        async with session.get(
            f"https://aleph.cloud/api/v0/storage/raw/{file_hash}"
        ) as response:
            if response.status != 200:
                response_text = await response.text()
                raise HTTPException(status_code=response.status, detail=response_text)

            return await response.read()

Is it intended only for this endpoint or for all of them?

I do not understand your question.

The url prefix /api/v0/storage/raw/{file_hash} exposes raw data as bytes from a file stored in Aleph builtin storage.

Fixed by #134