简体   繁体   English

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

[英]How to delete an image saved in IPFS blockchain?

I am working on a blockcahin based image sharing website in ethereum我正在以太坊中开发一个基于区块链的图像共享网站

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);
}

This is how you upload images but now I want user to delete images created by them how do i do it?这就是您上传图像的方式,但现在我希望用户删除他们创建的图像,我该怎么做?

You cannot delete an image from IPFS the way you interact with the database.您不能以与数据库交互的方式从 IPFS 中删除图像。 (giving the IPNS of the content and user sends an http request to delete it). (提供内容的 IPNS,用户发送 http 请求删除它)。

When you upload your content, you pin it to a node.当您上传您的内容时,您将其固定到一个节点。 Now the thing is the node that your content is pinned should be unpinned.现在问题是您的内容被固定的节点应该被取消固定。 So if you have a control over that node, If you started your own node, you unpin it and then ipfs will garbage collect it.因此,如果您可以控制该节点,如果您启动了自己的节点,则取消固定它,然后 ipfs 将垃圾收集它。

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

But if an image has been added and copied to another node, any person with the fingerprint can find it again.但是如果一个图像已经被添加并复制到另一个节点,任何有指纹的人都可以再次找到它。 So whoever controls that node should unpin it.因此,控制该节点的任何人都应该取消固定它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM