Remote Storage Provider

A Remote Storage Provider is an abstract class representing a provider for remote storage functionalities. This class is intended to be extended by a specific implementation of a remote storage provider. It offers methods to upload and download files, as well as the ability to monitor upload progress.

Usage

Below is a demonstration of extending the RemoteStorageProvider class for a custom implementation. You'll need to provide the actual logic for the upload and download methods based on your specific remote storage solution.

import type { FileInput } from '@4thtech-sdk/types';
import { RemoteStorageProvider } from '@4thtech-sdk/storage';

class MyRemoteStorageProvider extends RemoteStorageProvider {
  public async upload(file: FileInput, fileName: string): Promise<string> {
    // TODO: Implement the logic to upload the file to your storage.

    // Emitting the upload progress (for demonstration, assuming 100% here).
    this.emitUploadProgress(100, fileName);

    // Replace with the actual uploaded file URL.
    const uploadedFileUrl = 'https://your-storage.com/path-to-uploaded-file';
    return uploadedFileUrl;
  }

  public async download(url: string): Promise<ArrayBuffer> {
    // TODO: Implement the logic to download the file from your storage.

    // Replace with the actual file content.
    const fileContent = new ArrayBuffer(0);
    return fileContent;
  }
}
Previous
Storage