SDK Migration from <2.0.0 to >=2.0.0

Main Changes

Version 2.0.0 of the @spheron/storage (opens in a new tab) SDK brings significant changes and improvements.

Here are the main changes you need to be aware of when migrating from versions earlier than 2.0.0 to 2.0.0 or later:

1. Token Requirement

  • In versions prior to 2.0.0, the SDK required a token for a Static Site organization.
  • Starting from version 2.0.0, the SDK now requires a token for a Storage organization. All SDK usages are bound to this Storage organization.
  • Learn more about how to create an access token here.

2. Method and Interface Changes

Several methods and interfaces have undergone modifications to enhance functionality and usability:

  • getUpload - The Upload interface has changed. buildDirectory property is renamed to uploadDirectory, and now it is an array of with both the name and the size of the uploaded files. The UploadStatusEnum has also changed.
  • getOrganizationUsage - New properties have been added.
  • getBucket - The Bucket interface does not include the domains anymore. To fetch the domains of the bucket you can use the getBucketDomains method.
  • getBucketUploadCount - The method now only returns the total number of uploads.
  • getBucketUploads - The Upload interface has changed. buildDirectory property is renamed to uploadDirectory, and now it is an array of with both the name and the size of the uploaded files. The UploadStatusEnum has also changed.

3. IPNS Records

  • IPNS Records are now grouped at the bucket level. Please refer to the IPNS section for more detailed information.

Changes Required to Migrate

To migrate from a version of the SDK prior to 2.0.0 to version 2.0.0 or later, follow these steps:

  1. Make sure you are the owner of both the Static Site organization and the new Storage organization.

  2. Create an access token for the Storage organization. This token should be used when initializing the SpheronClient.

  3. Use the migrateStaticSiteOrgToStorage method provided in the documentation to migrate the buckets from your Static Site organization to the new Storage organization. This method will transfer the following data:

    • Buckets
    • Uploads
    • Domains
    • IPNS Records
⚠️

After you migrate the data it is not possible to revert it.

const { numberOfBuckets, numberOfUploads } =
  await client.migrateStaticSiteOrgToStorage(
    storageOrganizationId,
    staticSiteOrganizationId
  );

By following these steps, you can seamlessly transition to the latest version of the SDK (2.0.0 or later) while maintaining your existing data and taking advantage of the enhanced features it offers.

Storage UsageBrowser vs Storage