diff --git a/box/client.py b/box/client.py index 255f9b1..353222d 100644 --- a/box/client.py +++ b/box/client.py @@ -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): """ diff --git a/tests/test_client.py b/tests/test_client.py index e71f36d..bcac8c8 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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 = {