Skip to main content

Download file from Arcana Store

In this tutorial you will learn how to use Arcana Storage SDK and download a file from the distributed Arcana Store.

Prerequisites

  • Make sure your dApp is integrated with Arcana Storage SDK.
  • All prerequisites for integrating with Storage SDK must be met
  • The code in the steps section refers to StorageProvider object 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,
});

Steps

At a high level, downloading the file is a two step process that involves obtaining a Downloader from the Storage SDK and calling the download function with the specified file's DID.

Step 1: Get the Downloader

const Downloader = dAppStorageProvider.getDownloader();
// did: DID of the file that you wish to download in the dApp

Step 2: Call download function

Downloader.download(did);

Before downloading the file, depending upon the dApp use case, you may wish to first check if the file exists in Arcana Store. The file will be present if it was uploaded by the logged in dApp user or was shared with the user by the file owner. See storage metrics for details on how to list files for a logged in user.

What's Next?

If you are using Storage SDK with a third party wallet, you can also consider integrating with Arcana Auth SDK to ensure the privacy of your data by encrypting data before uploading and decrypt data after download.

See also