Skip to main content

How to enable custom file object storage

HAP supports using custom file object storage (based on the S3 standard, such as Alibaba Cloud OSS, Tencent Cloud COS, Huawei Cloud OBS, Qiniu Cloud, etc.) to replace the default storage service (based on MinIO). Follow the steps below to enable custom file object storage.

  1. Create a configuration file s3-config.json, with the template below (take Alibaba Cloud OSS as an example):

    {
    "mode": 1,
    "accessKeyID": "${Key}",
    "secretAccessKey": "${Secret}",
    "bucketEndPoint": "oss-cn-beijing.aliyuncs.com",
    "bucketName": {
    "mdmedia": "oss-mdtest",
    "mdpic": "oss-mdtest",
    "mdpub": "oss-mdtest",
    "mdoc": "oss-mdtest"
    },
    "region": "oss-cn-beijing"
    }

    Note: Currently, HAP system uses 4 buckets, mdmedia, mdpic, mdpub, mdoc. You can map the actual buckets used in the bucketName field of the configuration file.

  2. Mount configuration

    In standalone mode, modify the docker-compose.yaml file corresponding to the microservice application; in cluster mode, modify the docker-compose.yaml file corresponding to the file storage service.

    volumes:    
    -${s3-config.json host path}:/usr/local/file/s3-config.json
  3. Initialize the pre-made files

    You can use the tools provided by various object storage vendors to upload the contents of the pre-made file package (if migrating file storage for an existing HAP system, use the resources under /data/hap/script/volume/data/storage/data/ directory as pre-made files) (data in the mdmedia, mdpic, mdpub, mdoc 4 folders) to the corresponding bucket in the cloud according to the bucketName mapping. For example: HAP Private Deployment Alibaba Cloud OSS Initialization Instructions

  4. Restart HAP microservices