StorageBase#
StorageBase #
Bases: ABC
Abstract base class for storage systems. All subclasses are required to define certain attributes and implement specific methods for managing files
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the storage type. |
get_files
abstractmethod
async
#
get_files()
Abstract asynchronous method to get the files QuivrFile in the storage.
Returns:
| Type | Description |
|---|---|
list[QuivrFile]
|
list[QuivrFile]: A list of QuivrFile objects representing the files in the storage. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the method is not implemented. |
info #
info()
Returns information about the storage, including the storage type and the number of files.
Returns:
| Name | Type | Description |
|---|---|---|
StorageInfo |
StorageInfo
|
An object containing details about the storage. |
nb_files
abstractmethod
#
nb_files()
Abstract method to get the number of files in the storage.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of files in the storage. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the method is not implemented. |
remove_file
abstractmethod
async
#
remove_file(file_id)
Abstract asynchronous method to remove a file from the storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_id |
UUID
|
The unique identifier of the file to be removed. |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If the method is not implemented. |
upload_file
abstractmethod
async
#
upload_file(file, exists_ok=False)
Abstract asynchronous method to upload a file to the storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file |
QuivrFile
|
The file to upload. |
required |
exists_ok |
bool
|
If True, allows overwriting the file if it already exists. Default is False. |
False
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the method is not implemented. |
options: heading_level: 2