Skip to content

Commit 603797c

Browse files
🐛 Fix archive file was not closed after upload (#122)
* 🐛 Fix archive file was not closed after upload * Remove redundant comment --------- Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>
1 parent 14b0410 commit 603797c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/fastapi_cloud_cli/commands/deploy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ def _upload_deployment(deployment_id: str, archive_path: Path) -> None:
193193
upload_data = model_validate(RequestUploadResponse, response.json())
194194
logger.debug("Received upload URL: %s", upload_data.url)
195195

196-
# Upload the archive
197196
logger.debug("Starting file upload to S3")
198-
upload_response = client.post(
199-
upload_data.url,
200-
data=upload_data.fields,
201-
files={"file": archive_path.open("rb")},
202-
)
197+
with open(archive_path, "rb") as archive_file:
198+
upload_response = client.post(
199+
upload_data.url,
200+
data=upload_data.fields,
201+
files={"file": archive_file},
202+
)
203203

204204
upload_response.raise_for_status()
205205
logger.debug("File upload completed successfully")

0 commit comments

Comments
 (0)