protocol / nft-website

NFT School: Community education platform for developers in the non-fungible token space.
https://nftschool.dev
MIT License
360 stars 98 forks source link

Mint 3d model #246

Closed usama1050 closed 1 year ago

usama1050 commented 2 years ago

Hello! I checked your nft-school-examples/end-to-end code its working perfectly with the image files(png,jpg etc ) but not working when i mint 3d model I want to mint the 3d model (file format .glb). it gives me error on nft.storage

Error: property image must be a Blob or File object at this point

const metadata = await client.store({ name, description, image, // });

jochasinga commented 1 year ago

It should work with .glb file or any kind of binary file. You just have to convert it to Blob or File object before passing to store().

const  model = await fetch('/path/to/character.glb')
const imgdata = await model.blob()  // Convert to a Blob object
const image = new File([imgdata], 'character.glb', {type: 'model/gltf-binary'})
const nft = {
      image, // use image Blob as `image` field
      name: 'character.glb',
      description: 'Data of NFT #1',
      properties: { ...otherProps }
}
const metadata = await client.store(nft)

Let me know if this works or doesn't work for you and we can reopen this issue as needed. You're also very welcome to jump on Discord to get support.