如何删除保存在 IPFS 区块链中的图像?

How to delete an image saved in IPFS blockchain?

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

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

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