blockchain - 如何删除保存在 IPFS 区 block 链中的图像?

标签 blockchain ethereum solidity smartcontracts ipfs

我正在以太坊中开发基于区 block 链的图像共享网站

function uploadImage(string memory _imgHASH,string memory _description ) public{
 //making sure image ipfs hash exist
 require(bytes(_imgHASH).length > 0);
  //making sure that the image description exist
  require(bytes(_description).length > 0);

  require(msg.sender != address(0));

  //increment image id
  imageCount ++;

  //add image to contract
  images[imageCount] = Image(imageCount,_imgHASH,_description,0,msg.sender);


  //trigger an image
  emit ImageCreated(imageCount, _imgHASH, _description, 0, msg.sender);
}

这是您上传图片的方式,但现在我希望用户删除他们创建的图片,我该怎么做?

最佳答案

您不能以与数据库交互的方式从 IPFS 中删除图像。 (提供内容的 IPNS,用户发送 http 请求删除它)。

当您上传您的内容时,您将其固定到一个节点。现在问题是您的内容被固定的节点应该被取消固定。因此,如果您可以控制该节点,如果您启动了自己的节点,您可以取消固定它,然后 ipfs 将对其进行垃圾回收。

https://docs.ipfs.io/concepts/persistence/#garbage-collection

但是如果一个图像已经被添加并复制到另一个节点,任何有指纹的人都可以再次找到它。因此,无论谁控制该节点,都应该取消固定它。

关于blockchain - 如何删除保存在 IPFS 区 block 链中的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70650915/

相关文章:

cryptography - 在智能合约中隐藏部分结果

rest - 无法更改composer-rest-server的端口

blockchain - Hyperledger Fabric 的设置有什么问题?

blockchain - Corda - 使用 VaultCustomQueryCriteria 的问题

rust - Substrate:如何与 session 模块集成

go - geth account new - 命令行密码

ethereum - 使用智能合约功能从 Uniswap 获取货币对价格

blockchain - ERC20代币合约: does approve function need to check caller balance?

solidity - 如何在NFT智能合约中编写销毁函数?

solidity - 将结构数组传递给 Solidity Contract 的构造函数