fix(metadata): Fix metadata handling to address type assertion and data retrieval.

This commit is contained in:
2024-11-18 11:24:11 +01:00
parent 7db4d24817
commit e7f60465ff
6 changed files with 5746 additions and 5642 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartbucket',
version: '3.0.23',
version: '3.0.24',
description: 'A TypeScript library offering simple and cloud-agnostic object storage with advanced features like bucket creation, file and directory management, and data streaming.'
}

View File

@ -21,12 +21,12 @@ export class MetaData {
/**
* the file that contains the metadata
*/
metadataFile: File;
metadataFile!: File;
/**
* the file that the metadata is for
*/
fileRef: File;
fileRef!: File;
public async getFileType(optionsArg?: {
useFileExtension?: boolean;
@ -44,13 +44,13 @@ export class MetaData {
const stat = await this.fileRef.parentDirectoryRef.bucketRef.fastStat({
path: this.fileRef.getBasePath(),
});
return stat.ContentLength;
return stat.ContentLength!;
}
private prefixCustomMetaData = 'custom_';
public async storeCustomMetaData<T = any>(optionsArg: { key: string; value: T }) {
const data = await this.metadataFile.getContentsAsString();
const data = await this.metadataFile.getJsonData();
data[this.prefixCustomMetaData + optionsArg.key] = optionsArg.value;
await this.metadataFile.writeJsonData(data);
}