Skip to content

Commit

Permalink
fix(factory): handle missing content-length header more accurately
Browse files Browse the repository at this point in the history
- Change default `Content-Length` handling to use -1 instead of 0.
- Ensures file size is correctly identified when the header is absent.
  • Loading branch information
laipz8200 committed Oct 10, 2024
1 parent c8244c6 commit e4e03c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion api/factories/file_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _build_from_remote_url(
extension = "." + filename.split(".")[-1] if "." in filename else ".bin"

# Create the File object
file_size = int(resp.headers.get("Content-Length", 0))
file_size = int(resp.headers.get("Content-Length", -1))
mime_type = str(resp.headers.get("Content-Type", ""))
if not mime_type:
mime_type, _ = mimetypes.guess_type(url)
Expand Down

0 comments on commit e4e03c8

Please sign in to comment.