diff --git a/src/fastapi_cloud_cli/commands/deploy.py b/src/fastapi_cloud_cli/commands/deploy.py index 9046a57..dec422b 100644 --- a/src/fastapi_cloud_cli/commands/deploy.py +++ b/src/fastapi_cloud_cli/commands/deploy.py @@ -180,13 +180,13 @@ def _upload_deployment(deployment_id: str, archive_path: Path) -> None: upload_data = RequestUploadResponse.model_validate(response.json()) logger.debug("Received upload URL: %s", upload_data.url) - # Upload the archive logger.debug("Starting file upload to S3") - upload_response = client.post( - upload_data.url, - data=upload_data.fields, - files={"file": archive_path.open("rb")}, - ) + with open(archive_path, "rb") as archive_file: + upload_response = client.post( + upload_data.url, + data=upload_data.fields, + files={"file": archive_file}, + ) upload_response.raise_for_status() logger.debug("File upload completed successfully")