Swan Network
English
  • Getting Started
    • Overview
    • Protocol Stack
      • Cross-chain Consensus Layer
      • Peer-to-peer (P2P) Network
      • Payment Channels
      • Service Discovery
      • Data Marketplace
      • Indexing and Caching Marketplace
      • Web3 Task Auction
      • Storage Layer
      • Computing Layer
      • CDN Layer
      • Economic System
        • Grants
        • Computing Jobs
        • Universal Basic Income (UBI)
        • Swan Provider Income
      • Token
      • Governance
        • Treasure DAO
      • Glossary
    • Contact Us
      • Social Accounts & Communities
      • Business Partnerships
    • FAQ
  • QuickStarts
    • Dive into QuickStarts
      • Swan Chain: Developing Smart Contracts with Go
  • Swan Storage Market
    • Overview
      • Swan Auction System
      • Reputation System
    • Key functionalities
      • Task Management
        • Create a New Task
        • Navigate Tasks
        • Update Tasks
        • Assign Tasks
      • My Profile
        • Register as a storage provider
      • Find Storage Providers
        • Storage Provider Details
      • Extend DataCap Terms Service
  • Swan IPFS Storage
    • Overview
      • Flink
    • Swan IPFS Storage User Guide
      • Networks
      • Setup MetaMask
    • Developer Quickstart
      • SDK
        • js MCS SDK
          • Prerequisites
          • Get Started
          • Bucket Storage
          • Onchain Storage
          • SDK JS Installation Tutorial Video
        • python MCS SDK
          • Quickstart
          • Bucket Storage
          • Onchain Storage
          • SDK Python Installation Tutorial Video
      • Additional Resources
    • Best Practice
      • Use Swan IPFS Storage as Platform Storage Solution
        • Single Organization Design
        • Multiple Organization Design
    • FAQ
  • Swan Provider
    • Overview
    • Features
    • Tutorial
      • Prerequisites
      • Installation
      • Configure and Run
      • Swan Provider Tutorial Video
    • FAQ
      • 1. Change the linked Email
      • 2. Check Storage Provider connectivity/stability
      • 3. How to stop accepting "auto-bid" deals?
      • 4. `aria2_download_dir` vs. `aria2_candidate_dirs`
      • 5. How to configure "import deals from Swan Provider" when Boostd is running normally
      • 6. A rejection msg always appears during the deal-importing process
      • 7. How to check if aria2 is running?
      • 8. No response from Swan Platform?
      • 9. Why Storage Provider status shows offline?
      • 10. How to check the Task Status?
      • 11. How to configure the Storage Provider Market?
      • 12. How to set the "ask price"?
      • 13.aria2_download_dir VS. aria2_candidate_dirs
      • 14. How to control the number of deals imported?
  • Swan Client
    • Overview
    • Basic Concepts
    • Tutorial
      • Filecoin Deal Sender
        • Installation
        • Configuration
        • Prerequisites
        • Generate CAR Files
        • Meta-CAR
        • Upload CAR Files to IPFS
        • Create a Task
      • Blockchain RPC Service
        • Deploy RPC Service
        • RPC Command Service
      • Swan Client Tutorial Video
    • FAQ
      • How to prepare data?
  • FS3
    • Overview
    • Setup your FS3
      • Prerequisites
      • Install FS3
      • FS3 Set up Video
    • FS3 User Guide
    • FS3 User Guide (Cloud Version)
  • Lagrange DAO
    • Overview
  • Development Resource
    • Swan Token Contract
      • Acquire Testnet USDC and MATIC tokens
    • Swan API
    • Swan IPFS Storage API
    • Swan IPFS Storage 2.0 API
    • Flink API
    • FS3 API
    • API keys
  • Swan Testnet
    • Swan Jupiter Testnet
      • How to Participate
      • Before You Get Started
      • Network Early Adopter
      • Computing Provider Setup
        • Prerequisites
        • Install the Kubernetes
        • Install and config the Nginx
        • Install the Hardware resource-exporter
        • Install the Redis service
        • Build and config the Computing Provider
        • Install AI Inference Dependency(Optional)
        • Start the Computing Provider
        • CLI of Computing Provider
        • FAQ
      • FAQ
Powered by GitBook
On this page
  • Step-by-Step Tutorial
  • Login to Multichain Storage
  • Create Buckets for Organizations

Was this helpful?

  1. Swan IPFS Storage
  2. Best Practice
  3. Use Swan IPFS Storage as Platform Storage Solution

Multiple Organization Design

For multiple organizations or a organization has more function unit.

PreviousSingle Organization DesignNextFAQ

Last updated 23 days ago

Was this helpful?

Step-by-Step Tutorial

Login to Multichain Storage

Create Buckets for Organizations

Click "Bucket Storage" -> "Create Bucket", then enter your bucket name.

Use create multiple buckets for each organization or function.

Create folders for each user

First, install Swan IPFS Storage python SDK

pip install python-mcs-sdk

Swan IPFS Storage is a bucket-based object storage, insider bucket, folder, sub-folders and file name is defined as the object key, file content is defined as object value.

e.g. If we have a function called OnchainStorage and a user wallet 0x165CD37b4C644C2921454429E7F9358d18A45e14. Now we want to use this wallet as a folder name and upload a file called flower.jpeg

def upload_replace_file(file_path, bucket_name, dest_file_path):
    :param bucket_name: the bucket name user want to upload
    :param dest_file_path: the destination of the file you want to store exclude the bucket name
    :return: File Object
    """
    mcs_api = APIClient(api_key, access_token,network)
    bucket_client = BucketAPI(mcs_api)
    # check if file exist
    file_data = bucket_client.get_file(bucket_name, dest_file_path)
    if file_data:
        print("File exist,replace file: %s" % file_path)
        bucket_client.delete_file(bucket_name, dest_file_path)
    file_data = bucket_client.upload_file(bucket_name, dest_file_path, file_path)
    return file_data

Then we can upload the user file to the bucket:

mcs_file = upload_replace_file(file_path, "OchainStorage",os.path.join("0x165CD37b4C644C2921454429E7F9358d18A45e

You should see the following file stored in your multichain bucket.

This process can be repeated with other organizations or functions for your application.

Put everything together:

import os

from mcs import APIClient, BucketAPI


def upload_replace_file(file_path, bucket_name, dest_file_path):
    """
    Upload a file by file path, bucket name and the target path
    :param file_path: the source file path
    :param bucket_name: the bucket name user want to upload
    :param dest_file_path: the destination of the file you want to store exclude the bucket name
    :return: File Object
    """
    mcs_api = APIClient(api_key, access_token,network)
    bucket_client = BucketAPI(mcs_api)
    # check if file exist
    file_data = bucket_client.get_file(bucket_name, dest_file_path)
    if file_data:
        print("File exist,replace file: %s" % file_path)
        bucket_client.delete_file(bucket_name, dest_file_path)
    file_data = bucket_client.upload_file(bucket_name, dest_file_path, file_path)
    return file_data


if __name__ == '__main__':
    api_key = "XXXX"
    access_token = "xxxxxxx"
    network = "polygon.mainnet"
    file_path = 'data/apple.jpeg'
    # file_path is the path relative to the current file
    # object_name is your target path
    mcs_file = upload_replace_file(file_path, "OnchainStorage",
                                   os.path.join("0x165CD37b4C644C2921454429E7F9358d18A45e14", "apple.jpeg"))