Skip to content

Commit f0d63f6

Browse files
committed
properly close file before uploading to storage
1 parent fddbf7d commit f0d63f6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

testingbotclient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def __init__(self, client):
130130

131131
def upload_local_file(self, filepath):
132132
"""Uploads a local file to TestingBot Storage."""
133-
return requests.post(self.client.api_url + "/storage", files={'file': open(filepath, 'rb')}, auth=(self.client.testingbotKey, self.client.testingbotSecret)).json()
133+
with open(filepath, 'rb') as f: file_contents = f.read()
134+
return requests.post(self.client.api_url + "/storage", files={'file': file_contents}, auth=(self.client.testingbotKey, self.client.testingbotSecret)).json()
134135

135136
def upload_remote_file(self, remoteUrl):
136137
return self.client.post("/storage", { 'url': remoteUrl })

0 commit comments

Comments
 (0)