Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions box/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,19 @@ def copy_file(self, file_id, destination_parent, new_filename=None):
data['name'] = new_filename

return self._request("post", 'files/{}/copy'.format(file_id), data=data).json()
def update_fileinfo(self, file_id, fileinfo):
"""
Updates file info:
includes renaming, moving

Args:
- file_id: the id of the file we want to update
- fileinfo: dictionary containing the information to be updated

Returns:
- a dictionary with the new file metadata
"""
return self._request("put", 'files/{}'.format(file_id), data=fileinfo).json()

def share_link(self, file_id, access=ShareAccess.OPEN, expire_at=None, can_download=None, can_preview=None):
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,11 @@ def test_copy_file(self):
result = client.copy_file(123, 666, 'goatse.cx')
self.assertEqual({'id': '1'}, result)

def test_update_fileinfo(self):
client = self.make_client("put", 'files/123', data={'name': 'goodbye'}, result={'name': 'goodbye'})
result = client.update_fileinfo('123', {'name': 'goodbye'})
self.assertEqual({'name': 'goodbye'}, result)

def test_share_link(self):
# defaults
args = {
Expand Down