簡體   English   中英

如何刪除保存在 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

但是如果一個圖像已經被添加並復制到另一個節點,任何有指紋的人都可以再次找到它。 因此,控制該節點的任何人都應該取消固定它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM