Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions box/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def upload_file(self, filename, fileobj, parent=0, content_created_at=None, cont
- content_modified_at: (optional) a timestamp (datetime or a properly formatted string) of the time the
content was last modified
"""

try_refresh=True
form = {"parent_id": self._get_id(parent)}

if content_created_at:
Expand All @@ -631,7 +631,9 @@ def upload_file(self, filename, fileobj, parent=0, content_created_at=None, cont
form,
headers=self.default_headers,
files={filename: (filename, fileobj)})

if response.status_code == UNAUTHORIZED and try_refresh and self.credentials.refresh():
try_refresh=False
return self.upload_file(filename, fileobj)
self._check_for_errors(response)
return response.json()['entries'][0]

Expand Down