Custom

Create Custom StorageClient

import { StorageClient } from "@cloud-push/cloud";

const storageClient: StorageClient = {
    getFile: () => {},
    getFileSignedUrl: () => {},
    uploadDirectory: () => {},
    uploadFile: () => {},
    uploadLocalFile: () => {},
};

getFile

getFile({ key }: { key: string }): Promise<Uint8Array>

Fetches the file associated with the specified key from cloud storage and returns it as a Uint8Array.


getFileSignedUrl

getFileSignedUrl({ key, expiresIn }: { key: string; expiresIn?: number }): Promise<string>

Generates and returns a signed URL to access the specified file. expiresIn (optional) sets the expiration time of the URL in seconds.


uploadFile

uploadFile({
  key,
  file,
  contentType,
}: {
  key: string;
  file: Uint8Array;
  contentType?: string;
}): Promise<void>

Uploads a file in Uint8Array format to cloud storage. You can optionally specify the MIME type via contentType (default: "application/json").


uploadLocalFile

uploadLocalFile({
  fileName,
  filePath,
}: {
  fileName: string;
  filePath: string;
}): Promise<string | undefined>

Uploads a file from a local path using a stream, and returns the uploaded object's URL.


uploadDirectory

uploadDirectory({
  cloudPath,
  directoryPath,
}: {
  cloudPath: string;
  directoryPath: string;
}): Promise<void>

Uploads all files in a local directory to cloud storage.


Examples

import { defineConfig } from "@cloud-push/cli";
import { StorageClient } from "@cloud-push/cloud";


export default defineConfig(() => ({
  	loadClients: () => {
        
      const storageClient: StorageClient = {
          getFile: () => {},
          getFileSignedUrl: () => {},
          uploadDirectory: () => {},
          uploadFile: () => {},
          uploadLocalFile: () => {},
      };

      const dbClient: DbClient = {
        create: () => {},
        delete: () => {},
        find: () => {},
        findAll: () => {},
        readAll: () => {},
        toUint8Array: () => {},
        update: () => {},
      };

      return {
        storage: storageClient,
        db: dbClient,
      };
	},
}));