Skip to content

Commit 307ab82

Browse files
committed
fix contenttype
1 parent fe35c6a commit 307ab82

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ file = File(path="/path/to/file.png")
2121
# File with explicit metadata
2222
file = File(
2323
path="/path/to/file.png",
24-
mime_type="image/png",
24+
content_type="image/png",
2525
filename="custom_name.png",
2626
size=1024 # in bytes
2727
)
@@ -33,7 +33,7 @@ file = File.from_path("/path/to/file.png")
3333
exists = file.exists()
3434

3535
# Access file metadata
36-
print(file.mime_type) # automatically detected if not specified
36+
print(file.content_type) # automatically detected if not specified
3737
print(file.size) # file size in bytes
3838
print(file.filename) # basename of the file
3939

src/inferencesh/sdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class File(BaseModel):
103103
"""A class representing a file in the inference.sh ecosystem."""
104104
uri: str # Original location (URL or file path)
105105
path: Optional[str] = None # Resolved local file path
106-
mime_type: Optional[str] = None # MIME type of the file
106+
content_type: Optional[str] = None # MIME type of the file
107107
size: Optional[int] = None # File size in bytes
108108
filename: Optional[str] = None # Original filename if available
109109
_tmp_path: Optional[str] = PrivateAttr(default=None) # Internal storage for temporary file path
@@ -177,8 +177,8 @@ def __del__(self):
177177
def _populate_metadata(self) -> None:
178178
"""Populate file metadata from the path if it exists."""
179179
if os.path.exists(self.path):
180-
if not self.mime_type:
181-
self.mime_type = self._guess_mime_type()
180+
if not self.content_type:
181+
self.content_type = self._guess_content_type()
182182
if not self.size:
183183
self.size = self._get_file_size()
184184
if not self.filename:
@@ -189,7 +189,7 @@ def from_path(cls, path: Union[str, os.PathLike]) -> 'File':
189189
"""Create a File instance from a file path."""
190190
return cls(uri=str(path))
191191

192-
def _guess_mime_type(self) -> Optional[str]:
192+
def _guess_content_type(self) -> Optional[str]:
193193
"""Guess the MIME type of the file."""
194194
return mimetypes.guess_type(self.path)[0]
195195

tests/test_sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_file_creation():
1010
file = File(path="test.txt")
1111
assert file.exists()
1212
assert file.size > 0
13-
assert file.mime_type is not None
13+
assert file.content_type is not None
1414
assert file.filename == "test.txt"
1515

1616
os.remove("test.txt")

0 commit comments

Comments
 (0)