Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.md « snippets « administration « doc - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b53c2b1d108d13c155d06e8ebc1427946d76660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
stage: Create
group: Source Code
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments"
---

# Snippets **(FREE SELF)**

You can configure a maximum size for a snippet to prevent abuse.
The default limit is 52428800 bytes (50 MB).
The limit is applied when a snippet is created or updated.
The limit does not affect existing snippets unless they are updated and their
content changes.

## Configure the snippet size limit

To configure the snippet size limit, you can use the Rails console
or the [Application settings API](../../api/settings.md).

The limit **must** be in bytes.

This setting is not available in the [Admin Area settings](../settings/index.md).

### Use the Rails console

To configure this setting through the Rails console:

1. [Start the Rails console](../operations/rails_console.md#starting-a-rails-console-session).
1. Update the snippets maximum file size:

   ```ruby
   ApplicationSetting.first.update!(snippet_size_limit: 50.megabytes)
   ```

To retrieve the current value, start the Rails console and run:

  ```ruby
  Gitlab::CurrentSettings.snippet_size_limit
  ```

### Use the API

To set the limit by using the Application Settings API
(similar to [updating any other setting](../../api/settings.md#change-application-settings)),
use this command:

```shell
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>"
  --url "https://gitlab.example.com/api/v4/application/settings?snippet_size_limit=52428800"
```

You can also use the API to [retrieve the current value](../../api/settings.md#get-current-application-settings).

```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/application/settings"
```

## Related topics

- [User snippets](../../user/snippets.md)