
Before I begin, I must leave a link to the previous article , so that it is clear what exactly is meant.
In this article, I would like to parse the layer that is responsible for storing files, and how it can be used by anyone. Storacle is an independent library , there is no direct connection with music. You can organize the storage of any files.
In the previous article, I rolled the barrel a bit on ipfs , but this happened precisely in the context of the problem I was solving . In general, I think this project is cool. I just like the opportunity to create different networks for different tasks. This allows you to better organize the structure and reduce the load on individual nodes and the network as a whole. It is possible even within the framework of one project, if necessary, to break the network into pieces according to some criteria, reducing the overall load.
So, storacle uses a spreadable mechanism for networking. Key Features:
- Files can be added to the repository through any node.
- Files are saved in their entirety, not in blocks.
- Each file has its own unique hash on the contents for further work with it.
- Files can be duplicated for greater reliability.
- ( , )
- 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.
- , . , , .
- - . , .
- , , . .
: