Mondaic
This API reference is not for the latest stable Salvus version.

salvus.project.components.attachment_component

The attachment component for SalvusProject.

Allows one to attach any file up to a size limit in a Salvus project.

Classes

AttachmentComponent

class AttachmentComponent(builtins.object):
    def __init__(self, project: Project, path: pathlib.Path): ...

Project subclass handling attachments to a project.

Parameters
  • project Project — The project.
  • path pathlib.Path — Path to the attachment folder.
Methods
add()
def add(
    self,
    name: str,
    content: bytes | str | dict,
    overwrite: bool = False,
    description: str | None = None,
) -> None: ...

Add an attachment to the project.

Parameters
  • name str — Name of the file.
  • content bytes | str | dict — Content of the file.
  • overwrite bool — Whether to overwrite the file if it already exists.
  • description str | None — An optional description of the file.
Returns None
delete()
def delete(self, name: str) -> None: ...

Delete an attachment from disk and the project.

Parameters
  • name str — Name of the attachment to delete.
Returns None
detail_list()
def detail_list(self) -> typing.List[dict]: ...

List all attachments details.

Listed information is: - description; - size_in_bytes; - mime_type; - added_at.

Returns typing.List[dict]
get_content()
def get_content(self, name: str) -> bytes: ...

Get the content of an attachment as bytes.

Parameters
  • name str — Name of the attachment.
Returns bytes
get_content_dict()
def get_content_dict(self, name: str) -> dict: ...

Get the content of an attachment as a dictionary.

Only a limited set of file types (json) can be retrieved as dictionaries.

Parameters
  • name str — Name of the attachment.
Returns dict
get_content_str()
def get_content_str(self, name: str) -> str: ...

Get the content of an attachment as a string.

Only a limited set of file types (plaintext, markdown) can be retrieved as strings.

Parameters
  • name str — Name of the attachment.
Returns str
get_details()
def get_details(self, name: str) -> dict: ...

Get details of an attachment.

Parameters
  • name str — Name of the attachment.
Returns dict
list()
def list(self) -> list[str]: ...

List all attachments.

Returns list[str]