@require_api_auth()<EOL><INDENT>@require_oauth_scopes(write_scope.id)<EOL>@pass_record<EOL>@need_record_permission('<STR_LIT>')<EOL>def put(self, pid, record, key):<DEDENT>
try:<EOL><INDENT>data = json.loads(request.data.decode('<STR_LIT:utf-8>'))<EOL>new_key = data['<STR_LIT:filename>']<EOL><DEDENT>except KeyError:<EOL><INDENT>raise WrongFile()<EOL><DEDENT>new_key_secure = secure_filename(new_key)<EOL>if not new_key_secure or new_key != new_key_secure:<EOL><INDENT>raise WrongFile()<EOL><DEDENT>try:<EOL><INDENT>obj = record.files.rename(str(key), new_key_secure)<EOL><DEDENT>except KeyError:<EOL><INDENT>abort(<NUM_LIT>)<EOL><DEDENT>record.commit()<EOL>db.session.commit()<EOL>return self.make_response(obj=obj, pid=pid, record=record)<EOL>
Handle the file rename through the PUT deposit file.

        Permission required: `update_permission_factory`.

        :param pid: Pid object (from url).
        :param record: Record object resolved from the pid.
        :param key: Unique identifier for the file in the deposit.