Skip to content

Cell - Cloud Component ​

Shared abstractions of the cloud packages: where credentials, region and account come from, and the ObjectStorageService interface that @celljs/oss and @celljs/cos implement.

bash
npm install @celljs/cloud

Credentials, region, account ​

ComponentDefault source
CredentialsProvidercloud.credentials: { accessKeyId, accessKeySecret, token? }
RegionProvidercloud.region
AccountProvidercloud.account: { id }
ClientOptionsProvidercloud.client: extra options of the vendor client
yaml
cloud:
  region: cn-hangzhou
  credentials:
    accessKeyId: "${env.ACCESS_KEY_ID}"
    accessKeySecret: "${env.ACCESS_KEY_SECRET}"

Keep credentials in environment variables (${env.X} in cell.yml); configuration is server-only. Bind your own provider (rebind: true) to read them from somewhere else, such as a secrets manager.

Object storage ​

ObjectStorageService has createBucket, deleteBucket, listBuckets, listObjects, getObject, getStream, putObject, copyObject, deleteObject and headObject, with the same request shapes for every vendor:

ts
import { Autowired, Component } from '@celljs/core';
import { ObjectStorageService } from '@celljs/cloud';

@Component()
export class Uploads {
    @Autowired(ObjectStorageService)
    protected readonly storage: ObjectStorageService<any>;

    save(key: string, body: Buffer) {
        return this.storage.putObject({ bucket: 'uploads', key, body });
    }
}

Install one implementation: @celljs/oss (Alibaba Cloud) or @celljs/cos (Tencent Cloud). getRawCloudService() returns the vendor's own client for anything else.

Deploying an application to a cloud platform does not need this package: see the presets of cell deploy.