Storacle-分散的文件存储

图片


在开始之前,我必须保留指向上一篇文章链接,以便清楚地知道确切的含义。


在本文中,我想解析负责存储文件的层,以及任何人如何使用它。Storacle是一个独立的图书馆,与音乐没有直接联系。您可以组织任何文件的存储。


在上一篇文章中,我在ipfs上做了些改动,但这恰好是在我要解决的问题的背景下发生的。总的来说,我认为这个项目很棒。我只是喜欢有机会为不同的任务创建不同的网络。这使您可以更好地组织结构并减少单个节点和整个网络的负载。如有必要,即使在一个项目的框架内,也有可能根据某些标准将网络分成多个部分,从而减少总体负荷。


因此,storacle使用可扩展的网络机制主要特点:


  • 可以通过任何节点将文件添加到资源库。
  • 文件是完整保存的,不是成块保存的。
  • 每个文件在内容上都有其自己的唯一哈希,以供进一步使用。
  • 可以复制文件以提高可靠性。
  • ( , )
  • spreadable , ( )

, :


:


const  Node = require('storacle').Node;

(async () => {
  try {
    const node = new Node({
      port: 4000,
      hostname: 'localhost'
    });
    await node.init();
  }
  catch(err) {
    console.error(err.stack);
    process.exit(1);
  }
})();

:


const  Client = require('storacle').Client;

(async () => {
  try {
    const client = new  Client({
      address: 'localhost:4000'
    });
    await client.init();
    const hash = await client.storeFile('./my-file');
    const link = await client.getFileLink(hash); 
    await client.removeFile(hash);
  }
  catch(err) {
    console.error(err.stack);
    process.exit(1);
  }
})();


. , in-memory , . , - , . , (> ) . . "" , .


256 2 . . 1. 62500 (1000000 / sqrt(256)).


, , .


: , , , ... .



, , .
. . http .



javascript , . 
https://github.com/ortexx/storacle/blob/master/dist/storacle.client.js window.ClientStoracle ...



" ". , , , . , , , - . src . .


Api


  • async Client.prototype.storeFile()
  • async Client.prototype.getFileLink()
  • async Client.prototype.getFileLinks() — ,
  • async Client.prototype.getFileToBuffer()
  • async Client.prototype.getFileToPath()
  • async Client.prototype.getFileToBlob() — blob( )
  • async Client.prototype.removeFile()
  • Client.prototype.createRequestedFileLink()


, :


  • . ( )
  • . , , node.normalizeFilesInfo(), .
  • node.exportFiles(), .


, .
, .


  • storage.dataSize
  • storage.tempSize
  • storage.autoCleanSize — , . , .
  • file.maxSize
  • file.minSize
  • file.preferredDuplicates
  • file.mimeWhitelist
  • file.mimeBlacklist
  • file.extWhitelist
  • file.extBlacklist
  • file.linkCache

, .



. : npm i -g storacle. , . , storacle -a storeFile -f ./file.txt -c ./config.js, . https://github.com/ortexx/storacle/blob/master/bin/actions.js



  • - , . , , , storacle.
  • , . , , .
  • - . , .
  • , , . .

:



All Articles