digitaltwin-core
Version:
Minimalist framework to collect and handle data in a Digital Twin project
72 lines • 3.27 kB
TypeScript
import { StorageService } from '../storage_service.js';
export interface OvhS3Config {
accessKey: string;
secretKey: string;
endpoint: string;
region?: string;
bucket: string;
}
export declare class OvhS3StorageService extends StorageService {
#private;
constructor(config: OvhS3Config);
/**
* Uploads a file to the OVH S3-compatible object storage.
* @param buffer - File contents to upload
* @param collectorName - Folder/prefix to store under
* @param extension - Optional file extension (e.g. 'json')
* @returns The relative path (key) of the stored object
*/
save(buffer: Buffer, collectorName: string, extension?: string): Promise<string>;
/**
* Downloads and returns a stored object as a Buffer.
* @param relativePath - The key/path of the object to retrieve
* @returns The object contents as a Buffer
*/
retrieve(relativePath: string): Promise<Buffer>;
/**
* Deletes an object from the storage bucket.
* @param relativePath - The key/path of the object to delete
*/
delete(relativePath: string): Promise<void>;
/**
* Uploads a file to OVH S3 at a specific path (preserves filename).
* Unlike save(), this method does not auto-generate a timestamp filename.
* Files are uploaded with public-read ACL for direct access (e.g., Cesium tilesets).
* @param buffer - File contents to upload
* @param relativePath - Full relative path including filename (e.g., 'tilesets/123/tileset.json')
* @returns The same relative path that was provided
*/
saveWithPath(buffer: Buffer, relativePath: string): Promise<string>;
/**
* Deletes multiple objects in batch using S3 DeleteObjects API.
* Much faster than individual deletes - can delete up to 1000 objects per request.
* @param paths - Array of object keys to delete
*/
deleteBatch(paths: string[]): Promise<void>;
/**
* Returns the public URL for a stored file.
* Constructs the OVH S3 public URL format: https://{bucket}.{endpoint_host}/{key}
* @param relativePath - The storage path/key of the file
* @returns The public URL to access the file directly
*/
getPublicUrl(relativePath: string): string;
/**
* Deletes all objects under a given prefix (folder).
* Lists objects by prefix and deletes them in batches for performance.
* @param prefix - The folder/prefix to delete (e.g., 'tilesets/123')
* @returns Number of files deleted
*/
deleteByPrefix(prefix: string): Promise<number>;
/**
* Configure CORS settings for the bucket.
* Required for browser-based access to public files (e.g., Cesium loading tilesets).
* Should be called once during application startup.
*
* @param allowedOrigins - List of allowed origins (default: ['*'])
* @param allowedMethods - List of allowed HTTP methods (default: ['GET', 'HEAD'])
* @param allowedHeaders - List of allowed headers (default: ['*', 'Authorization'])
* @returns true if successful, false otherwise
*/
configureCors(allowedOrigins?: string[], allowedMethods?: string[], allowedHeaders?: string[]): Promise<boolean>;
}
//# sourceMappingURL=ovh_storage_service.d.ts.map