> For the complete documentation index, see [llms.txt](https://wpcloudplugins.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wpcloudplugins.gitbook.io/docs/developers/api/patch.md). Agents can also search and read this documentation through its [MCP server](https://wpcloudplugins.gitbook.io/docs/~gitbook/mcp).

# patch()

## Patch a file or folder

&#x20; <mark style="background-color:orange;">patch()</mark> &#x20;

Update an file. This can be e.g. used to rename a file.

{% tabs %}
{% tab title="OneDrive" %}

### **Parameters**

<table><thead><tr><th width="215">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry that should be updated.</td></tr><tr><td><code>$update_request</code></td><td>array</td><td>The content that should be patched. E.g. <code>['name' => 'new_name'].</code></td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="194">Name</th><th width="166">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_ONEDRIVE_API::set_account_by_id('8c9bacda0-d8d8-4b22-b634-7b5281687575');
WPCP_ONEDRIVE_API::set_drive_by_id('b!DlaHWskCed_MIid3KpJH5Lbatf9HsdXBAZH5YcvPAbMhJUKzTJyzgvXZYpBS');

// Update request to rename, and add a description
$updaterequest = [
  'name' => 'Another picture.jpg',
  'description' => 'Nunc sit amet convallis ante, nec molestie leo. Duis quis egestas arcu. Sed lacinia imperdiet tellus et molestie. Nulla at ornare diam, ac pretium augue. '
];

// Patch the file or folder
$node = WPCP_ONEDRIVE_API::patch('01EXLSWHWMQZNDMLRG7NFIWAVYCFJAXP2R', $updaterequest);
```

{% endtab %}

{% tab title="Google Drive" %}

### **Parameters**

<table><thead><tr><th width="206">Name</th><th width="308">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry that should be updated.</td></tr><tr><td><code>$update_request</code></td><td><strong>UYDGoogle_Service_Drive_DriveFile</strong></td><td>An object containing the requested patch.</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="184">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_GDRIVE_API::set_account_by_id('201096615285735764133')

// Update request to rename, and add a description
$update_request = new \UYDGoogle_Service_Drive_DriveFile();
$update_request->setName('Another picture.jpg');
$update_request->setDescription('Nunc sit amet convallis ante, nec molestie leo. Duis quis egestas arcu. Sed lacinia imperdiet tellus et molestie. Nulla at ornare diam, ac pretium augue.');

// Patch the file or folder
$node = WPCP_GDRIVE_API::patch('1wzWlDMsZkA4N5yEEAmMigp52u7M0Lk_7', $update_request);
```

{% endtab %}

{% tab title="Dropbox" %}

### **Not supported**

{% endtab %}

{% tab title="Box" %}

### **Parameters**

<table><thead><tr><th width="209">Name</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry that should be updated.</td></tr><tr><td><code>$update_request</code></td><td>array</td><td>The content that should be patched. E.g. <code>['name' => 'new_name'].</code></td></tr><tr><td><code>$is_dir</code></td><td>bool</td><td>Is the entry a folder or a file?</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="210">Name</th><th width="146">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_BOX_API::set_account_by_id('29232154182');

// Update request to rename, and add a description
$updaterequest = [
  'name' => 'Another picture.jpg',
  'description' => 'Nunc sit amet convallis ante, nec molestie leo. Duis quis egestas arcu. Sed lacinia imperdiet tellus et molestie. Nulla at ornare diam, ac pretium augue. '
];

// Patch the file or folder
$node = WPCP_BOX_API::patch('51142665', $updaterequest, false);
```

{% endtab %}
{% endtabs %}
