> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quickblox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update File

> Update file metadata and/or its content.

#### Recipes

<AccordionGroup>
  <Accordion title="Replace file with new file">
    <Steps>
      <Step title="1. Use a `blob` parameter to set blob fields">
        ```curl {5-6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
          }
        }' \
        https://api.quickblox.com/blobs/10119859.json
        ```
      </Step>

      <Step title="2. Update a file content to new">
        Set a `new to 1` in the blob to update the file content.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{
            "new":"1"  
          }
        }' \
        https://api.quickblox.com/blobs/10119859.json
        ```
      </Step>

      <Step title="3. As a result, the file is replaced with a new one.">
        ```json theme={null}
        {
          "blob": {
            "id": 10119859,
            "uid": "5b40013845324e798902f9bf94fc687b00",
            "content_type": "image/jpeg",
            "name": "apple.jpeg",
            "size": 6743,
            "created_at": "2020-09-15T11:12:00Z",
            "updated_at": "2020-09-15T11:12:12Z",
            "blob_status": null,
            "set_completed_at": "2020-09-15T11:12:02Z",
            "public": true,
            "account_id": 102190,
            "app_id": 74829,
            "blob_object_access": {
              "id": 10119859,
              "blob_id": 10119859,
              "expires": "2020-09-15T12:12:12Z",
              "object_access_type": "Write",
              "params": "https://api.quickblox.com/blobs/10119859/upload/?acl=public-read&content_type=image%2Fjpeg&expires=2020-09-15%2012%3A12%3A12%20UTC&key=5b40013845324e798902f9bf94fc687b00&policy=YTAyMTM4ZGUyNzk2ZWRmZDA4MTg0NjQ2OGUwYTZhNjk%3D%0A&success_action_status=201&x-amz-algorithm=AWS4-HMAC-SHA256&x-amz-credential=160e31c718a12f1b46e8b347fea52e4d%2F20200915%2Fqbprod%2Fs3%2Faws4_request&x-amz-date=2020259T1212Z&x-amz-signature=a6d47838690dffcec8cb0a7d2059faaa"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Update file name">
    <Steps>
      <Step title="1. Use a `blob` parameter to set blob fields">
        ```curl {5-6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
          }
        }' \
        https://api.quickblox.com/blobs/9715927.json
        ```
      </Step>

      <Step title="2. Set a new file name">
        Set a new file `name` in the blob.

        ```curl {6} theme={null}
        curl -X PUT \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{
            "name":"apple" 
          }
        }' \
        https://api.quickblox.com/blobs/9715927.json
        ```
      </Step>

      <Step title="3. As a result, the API returns a file with an updated name.">
        ```json theme={null}
        {
          "blob": {
            "id": 9715867,
            "uid": "9dc0d37c9be34c839ae3bcac4bbaace100",
            "content_type": "image/jpeg",
            "name": "apple",
            "size": 16766,
            "created_at": "2019-09-15T19:40:18Z",
            "updated_at": "2019-09-15T20:35:45Z",
            "blob_status": "complete",
            "set_completed_at": "2019-09-15T20:00:46Z",
            "public": false
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

Update a file name, content type or file tag list. You can also update the file content by setting `new=1`
parameter. Once set, the file is deleted in the cloud storage and a new record is created. Consequently,
all file fields, except for the `name`, are updated in the cloud storage including the `uid`, `size`, etc.

#### Path Parameters

<ParamField path="blob_id" type="integer" required>
  ID of the file/blob. Generated automatically by the server after file/blob creation.
</ParamField>

#### Body Parameters

<ParamField body="blob" type="object" required>
  <Expandable title="properties">
    <ParamField body="content_type" type="string" required>
      <Tooltip tip="MIME content type - Multipurpose Internet Mail Extensions (MIME) is an Internet standard extending the format of email messages by supporting text in character sets other than ASCII, and attachments such as audio, video, images, and application programs."> MIME content type</Tooltip>
    </ParamField>

    <ParamField body="name" type="string" required>File/blob name</ParamField>
    <ParamField body="tag_list" type="string"> Should be a comma-separated string with tags.</ParamField>
    <ParamField body="new" type="string"> Use it to update the content of the blob file. Set `new=1` to proceed.</ParamField>
  </Expandable>
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required> A user or application session token. See [Authentication](/reference/authentication) page to learn more about session tokens. Must be used either QB-Token or Authorization. </ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="200">
    A successful response

    <ResponseField name="blob" type="object">
      <Expandable title="properties">
        <ResponseField name="id" type="integer" />

        <ResponseField name="uid" type="string" />

        <ResponseField name="content_type" type="string" />

        <ResponseField name="name" type="string" />

        <ResponseField name="size" type="string" />

        <ResponseField name="created_at" type="string" />

        <ResponseField name="updated_at" type="string" />

        <ResponseField name="blob_status" type="string" />

        <ResponseField name="set_completed_at" type="string" />

        <ResponseField name="public" type="boolean" />
      </Expandable>
    </ResponseField>
  </Accordion>

  <Accordion title="403">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT \
  -H "Content-Type: application/json" \
  -H "QB-Token: ee0959fe70ddaf8d1a04e8ed6425bdd9f4012bba" \
  -d '{  
    "blob":{  
      "name":"apple"
    }
  }' \
  https://api.quickblox.com/blobs/9715927.json
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "blob": {
      "id": 9715867,
      "uid": "9dc0d37c9be34c839ae3bcac4bbaace100",
      "content_type": "image/jpeg",
      "name": "apple",
      "size": 16766,
      "created_at": "2019-09-15T19:40:18Z",
      "updated_at": "2019-09-15T20:35:45Z",
      "blob_status": "complete",
      "set_completed_at": "2019-09-15T20:00:46Z",
      "public": false
    }
  }
  ```

  ```json 403 theme={null}
  {
    "errors": [
      "Forbidden"
    ]
  }
  ```
</ResponseExample>
