kodadot / stick

GraphQL service for Uniques and Assets on Asset Hubs
MIT License
4 stars 10 forks source link

Store MimeType and Thumbnail on Indexer #178

Open preschian opened 8 months ago

preschian commented 8 months ago

Hi, @kodadot/internal-dev, I need help with someone already familiar with indexer. I added new endpoints on our image-workers:

/metadata endpoint

With the /metadata endpoint, we can get mimeType for media and animated media

https://image-beta.w.kodadot.xyz/metadata?url=https%3A%2F%2Fimage-beta.w.kodadot.xyz%2Fipfs%2Fbafybeif7qqgorl7bf5227jeg337qlwlqdi6t3p3cuxhn4mnzw6ffkbqdla%2F111.json

will return

{
    "imageMimeType": "image/jpeg",
    "animationUrlMimeType": "text/html",
    ...
}

Or, you can directly call HEAD request to the metadata itself.

I think once we can store that on the indexer, we can continue with these issues:

/video endpoint

With the /video endpoint, we can upload video to cf-stream. Once the processing is done, we can get the video thumbnail. Once we can store the proper thumbnail in the indexer, we can fix our preview image:

Metadata from one of the items for that collection is something like this:

{
    "name": "Polkadot @ EthDenver 2023",
    "image": "ipfs://ipfs/QmT2yg18YvYdECQcy5VJ4NYUd1dvVUjxJEhqiKBcMgS5UF",
    "description": "Polkadot @ EthDenver 2023"
}

As you can see, the actual media is video. But it is stored in the image key. And there is no metadata for the actual image/thumbnail.

Why we need to store it on the indexer: check MimeType on the client, which will be flooded on the network request. Loading all mp4s on the explorer will be laggy for the user. https://github.com/kodadot/nft-gallery/pull/6364#pullrequestreview-1506630564

roiLeo commented 8 months ago

maybe something can be done with https://github.com/kodadot/stick/blob/cb6133ed1dd16d440db60660c461a988dcc9dcae/src/mappings/utils/metadata.ts#L9