Skip to content

Commit

Permalink
Update handling files in storage
Browse files Browse the repository at this point in the history
  • Loading branch information
NikAzanov committed May 23, 2024
1 parent ce54532 commit 4ebe105
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pytest_qaseio/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ def save_file_obj(self, content: bytes, filename: str) -> str:
...


class FileIO(io.BytesIO):
"""Represent file object to pass in Qase API methods.
Set `name` and `mime` attributes to objects since it's required in
https://github.com/qase-tms/qase-python/blob/44d19a500246017a30e0fa06b35cace065135d96/qaseio/src/qaseio/api_client.py#L518
"""

mime = "application/octet-stream"

def __init__(self, *args, filename: str, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.name = filename


class QaseFileStorage:
"""Upload files to Qase S3 bucket as attachment."""

Expand All @@ -33,8 +48,7 @@ def __init__(

def save_file_obj(self, content: bytes, filename: str) -> str:
"""Upload file to Qase.io S3 bucket via attachment API."""
file_obj = io.BytesIO(content)
file_obj.name = filename
file_obj = FileIO(content, filename=filename)

attachment_response_result = (
qaseio.AttachmentsApi(
Expand Down

0 comments on commit 4ebe105

Please sign in to comment.