The setstoragecfg table allows setting limits to the LiquidStorage service for users. This is an optional step.
TABLE storagecfg { // all measurements in bytesuint64_t max_file_size_in_bytes = UINT64_MAX; // max file size in bytes that can be uploaded at a time, default 10mbuint64_t global_upload_limit_per_day = UINT64_MAX; // max upload limit in bytes per day for EOS account, default 1 GBuint64_t vaccount_upload_limit_per_day = UINT64_MAX; // max upload limit in bytes per day for LiquidAccounts, default 10 MB};
Here we will set the maximum file size to 1MB and the global upload limits to 10MB each. You can update the YOUR_ACCOUNT_HERE to your consumer account.
This test will use a regular EOS account instead of a LiquidAccount, to use a LiquidAccount, visit the LiquidAccount section for how to send a transaction.
touchtest.js# add contents belowvimtest.js# run filenodetest.js
const { createClient } =require('@liquidapps/dapp-client');constfetch=require('isomorphic-fetch');constendpoint="https://kylin-dsp-2.liquidapps.io";constgetClient= () =>createClient( { network:"kylin", httpEndpoint: endpoint, fetch });(async () => {constservice=await (awaitgetClient()).service('storage',"YOUR_ACCOUNT_HERE");constdata=Buffer.from("a great success","utf8");constkey="YOUR_ACTIVE_PRIVATE_KEY_HERE";constpermission="active";constoptions= {// if true, DAG leaves will contain raw file data and not be wrapped in a protobuf rawLeaves:true };constresponse=awaitservice.upload_public_file( data, key, permission,null, options );console.log(`response uri: ${response.uri}`);})().catch((e) => { console.log(e); });
# node test.js responseuri:ipfs://IPFS_URI_HERE
This will return the IPFS URI where the content can be fetched.
Add the URI to the end of the IPFS gateway: https://ipfs.io/ipfs/IPFS_URI_HERE, and you will see “a great success”.
To fetch data, the following example can be used:
constfetch=require("node-fetch");(async () => {let res =awaitfetch('https://kylin-dsp-2.liquidapps.io/v1/dsp/liquidstorag/get_uri', { method:'POST', mode:'cors', body:JSON.stringify({ uri:"ipfs://zb2rhX28fttoDTUhpmHBgQa2PzjL1N3XUDaL9rZvx8dLZseji" }) }); res =awaitres.json(); res =Buffer.from(res.data,'base64').toString(),console.log(`result: ${res}`);})().catch((e) => { console.log(e); });// result: a great success
To see additional examples of the other dapp-client services, see the examples folder here.