Skip to main content

Get Storage Usage Metrics

In this tutorial you will learn how to obtain dApp user storage metrics such as the list of files uploaded to Arcana Store by the user, the list of files shared with the current logged in user and the storage, bandwidth consumed by the user.

Prerequisites

  • Make sure your dApp is integrated with Arcana Storage SDK.
  • The code in the steps section refer to StorageProvider and Access objects initialized during Storage SDK integration:
import { StorageProvider } from '@arcana/storage/dist/standalone/storage.umd';

dAppStorageProvider = new StorageProvider({
appId: ARCANA_APP_ID,
provider: window.ethereum,
email: user_email_string,
});

const Access = new dAppStorageProvider.getAccess();

Get Storage Metrics for the logged in user

Note that all these metrics are in the context of the current logged in dApp user.

Get list of files uploaded

//Get a list of files shared with the current logged in user from Arcana Store
let files = await dAppStorageProvider.sharedFiles();

Get list of files shared

//Get a list of files uploaded by the current logged in user into Arcana Store
let files = await dAppStorageProvider.myFiles();

Get storage usage metrics

Use the following file storage access object methods to get the storage usage metrics:

//Get consumed and total storage of the current user
let [consumed, total] = await Access.getUploadLimit();

//Get consumed and total bandwidth of the current user
let [consumed, total] = await Access.getDownloadLimit();

What's Next?

You can use the StorageProvider interface to also upload, download files to Arcana store.

See also