Video & NFT using Moralis

Can I upload video as an NFT using moralis? If yes, then where I will store the video? And please provide me the doc for uploading video as NFT.

Thanks in advance.

You can save the video to IPFS and use the ipfs url in nft metadata.
https://docs.moralis.io/moralis-dapp/files/ipfs#saving-files

2 Likes

Hi @muhtasim
Yes, you can upload upto 1 GB of file (image or video) in IPFS, your file wont be stored in blockchain because its too large so we will store in a peer-to-peer storage protocol called IPFS.

// Save video file input to IPFS
const data = fileInput.files[0];
const videoFile = new Moralis.File(data.name, data);
await videoFile.saveIPFS();

console.log(file.ipfs(), file.hash())

// This saves the video file to IPFS

// You can also save to Moralis DB as reference to use it later as records.

// Save file reference to Moralis
const jobApplication = new Moralis.Object("Applications");
jobApplication.set("name", "Name of Video File");
jobApplication.set("resume", VideoFile);
await jobApplication.save();

// Retrieve file
const query = new Moralis.Query("Applications");
query.equalTo("name", "Satoshi");
query.find().then(function ([application]) {
  const ipfs = application.get("resume").ipfs();
  const hash = application.get("resume").hash();
  console.log("IPFS url", ipfs);
  console.log("IPFS hash", hash);
});

When you retrieve the data from IPFS you can use the URL from IPFS and store as tokeURI

Check this out: https://docs.openzeppelin.com/contracts/2.x/erc721#constructing_an_erc721_token_contract

You can call _setTokenURI() and pass URL in second argument of the function.

All the best

1 Like

Thank you so much. I can upload video as NFT.