Test

Set LiquidStorage Configuration

The setstoragecfg table allows setting limits to the LiquidStorage service for users. This is an optional step.
1
TABLE storagecfg {
2
// all measurements in bytes
3
uint64_t max_file_size_in_bytes = UINT64_MAX; // max file size in bytes that can be uploaded at a time, default 10mb
4
uint64_t global_upload_limit_per_day = UINT64_MAX; // max upload limit in bytes per day for EOS account, default 1 GB
5
uint64_t vaccount_upload_limit_per_day = UINT64_MAX; // max upload limit in bytes per day for LiquidAccounts, default 10 MB
6
};
Copied!
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.
1
cleos -u https://kylin.eosn.io push transaction '{"delay_sec":0,"max_cpu_usage_ms":0,"actions":[{"account":"YOUR_ACCOUNT_HERE","name":"setstoragecfg","data":{"max_file_size_in_bytes":1000000,"global_upload_limit_per_day":100000000,"vaccount_upload_limit_per_day":100000000},"authorization":[{"actor":"YOUR_ACCOUNT_HERE","permission":"active"}]}]}'
Copied!

Test

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.
First install the dapp-client​
1
npm install -g @liquidapps/dapp-client
Copied!
Create the following file:
1
touch test.js
2
# add contents below
3
vim test.js
4
# run file
5
node test.js
Copied!
1
const { createClient } = require('@liquidapps/dapp-client');
2
const fetch = require('isomorphic-fetch');
3
const endpoint = "https://kylin-dsp-2.liquidapps.io";
4
const getClient = () => createClient( { network:"kylin", httpEndpoint: endpoint, fetch });
5
​
6
(async () => {
7
const service = await (await getClient()).service('storage', "YOUR_ACCOUNT_HERE");
8
const data = Buffer.from("a great success", "utf8");
9
const key = "YOUR_ACTIVE_PRIVATE_KEY_HERE";
10
const permission = "active";
11
const options = {
12
// if true, DAG leaves will contain raw file data and not be wrapped in a protobuf
13
rawLeaves: true
14
};
15
const response = await service.upload_public_file(
16
data,
17
key,
18
permission,
19
null,
20
options
21
);
22
console.log(`response uri: ${response.uri}`);
23
})().catch((e) => { console.log(e); });
Copied!
1
# node test.js
2
response uri: ipfs://IPFS_URI_HERE
Copied!
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:
1
const fetch = require("node-fetch");
2
​
3
(async () => {
4
let res = await fetch('https://kylin-dsp-2.liquidapps.io/v1/dsp/liquidstorag/get_uri', {
5
method: 'POST',
6
mode: 'cors',
7
body: JSON.stringify({ uri: "ipfs://zb2rhX28fttoDTUhpmHBgQa2PzjL1N3XUDaL9rZvx8dLZseji" })
8
});
9
res = await res.json();
10
res = Buffer.from(res.data, 'base64').toString(),
11
console.log(`result: ${res}`);
12
})().catch((e) => { console.log(e); });
13
// result: a great success
Copied!
To see additional examples of the other dapp-client services, see the examples folder here.