---
title: "Attachments"
description: "Learn more about how Sentry can store additional files in the same request as event attachments."
url: https://docs.sentry.io/platforms/unity/enriching-events/attachments/
---

# Attachments | Sentry for Unity

Sentry can enrich your events for further investigation by storing additional files, such as config or log files, as attachments.

## [Creating Attachments](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#creating-attachments)

The simplest way to create an attachment is to use a `path`. The SDK will read the contents of the file each time it prepares an event or transaction, then adds the attachment to the same [envelope](https://develop.sentry.dev/sdk/data-model/envelopes/). If the SDK can't read the file, the SDK logs an error message and drops the attachment.

```csharp
SentrySdk.ConfigureScope(scope =>
{
    scope.AddAttachment(Path.Combine(Application.persistentDataPath, "file.log"));
});
```

Note that there are restrictions in place when using paths in combination with [StreamingAssets](https://docs.unity3d.com/2019.4/Documentation/Manual/StreamingAssets.html) and the [Resource folder](https://docs.unity3d.com/ScriptReference/Resources.html).

Alternately, use `bytes` to initialize an attachment. When doing so, you also need to specify a filename.

```csharp
SentrySdk.ConfigureScope(scope =>
{
    // Add an in-memory attachment to the current scope
    scope.AddAttachment(bytes, "file.log");
});
```

With [Offline Caching](https://docs.sentry.io/platforms/unity/configuration/options.md#InitCacheFlushTimeout) enabled, each attachment is stored to disk for each event or transaction you capture when the device is offline. When using large attachments, this storage can consume the disk space if the device is offline for a longer time period.

In addition, you can set these parameters:

`filename`

The filename is the name of the file to display in Sentry. When using bytes you have to specify a filename, whereas with a path you don't as the SDK is going to use the last path component.

`contentType`

The type of content stored in this attachment. Any [MIME type](https://www.iana.org/assignments/media-types/media-types.xhtml) may be used; the default is `application/octet-stream`.

`mimetype`

The specific media content type that determines how the attachment is rendered in the Sentry UI. We currently support and can render the following MIME types:

* `text/plain`
* `text/css`
* `text/csv`
* `text/html`
* `text/javascript`
* `text/json` or `text/x-json` or `application/json` or `application/ld+json`
* `image/jpeg`
* `image/png`
* `image/gif`
* `image/webp`
* `image/avif`
* `video/webm`
* `video/mp4`

## [Uploading Attachments](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#uploading-attachments)

Unity features a global [scope](https://docs.sentry.io/platforms/unity/enriching-events/scopes.md) to which you add an attachment that will be sent with every event.

```csharp
SentrySdk.ConfigureScope(scope =>
{
    scope.AddAttachment(Path.Combine(Application.persistentDataPath, "file.log"));
});

SentrySdk.ConfigureScope(scope =>
{
    scope.ClearAttachments();
});
```

Sentry allows at most 40MB for a compressed request, and at most 200MB of uncompressed attachments per event, including the crash report file (if applicable). Uploads exceeding this size are rejected with HTTP error `413 Payload Too Large` and the data is dropped immediately. To add larger or more files, consider secondary storage options.

Attachments persist for 30 days; if your total storage included in your quota is exceeded, attachments will not be stored. You can delete attachments or their containing events at any time. Deleting an attachment does not affect your quota - Sentry counts an attachment toward your quota as soon as it is stored.

Learn more about how attachments impact your [quota](https://docs.sentry.io/pricing/quotas.md).

### [Access to Attachments](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#access-to-attachments)

To limit access to attachments, navigate to your organization's **General Settings**, then select the *Attachments Access* dropdown to set appropriate access — any member of your organization, the organization billing owner, member, admin, manager, or owner.

By default, access is granted to all members when storage is enabled. If a member does not have access to the project, the ability to download an attachment is not available; the button will be greyed out in Sentry. The member may only view that an attachment is stored.

## [Store Minidumps as Attachments](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#store-minidumps-as-attachments)

[Minidumps](https://docs.sentry.io/platforms/native/guides/minidumps.md#what-is-a-minidump) may contain sensitive information about the target system, such as environment variables, local pathnames, or in-memory representations of input fields, including passwords. By default, Sentry only uses minidump files to create events and immediately drops them. All sensitive information is stripped from the resulting events.

All attachments types, including log files, screenshots and minidumps (if you enable Store Minidumps As Attachments), are stored for 30 days when sent to Sentry. Note that Sentry does not apply data scrubbing to attachments.

☝ This feature is supported on Windows, Linux, and Android.

### [Enabling Minidump Storage](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#enabling-minidump-storage)

You can enable *Store Minidumps As Attachments* in your organization or project settings under **Security & Privacy**. By default, this setting is disabled. Determine the maximum number of crash reports that will be stored per issue; disabled, unlimited, or maximum per issue:

If you set a limit per issue, as in the example above, a limit of 5, Sentry will store the first 5 attachments associated with this issue, but drop any that follow. To make room for additional attachments, delete them. Sentry will then accept attachments until the limit is reached again.

## [Viewing Attachments](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#viewing-attachments)

Attachments display on the bottom of the **Issue Details** page for the event that is shown.

Alternately, attachments also appear in the *Attachments* tab on the **Issue Details** page, where you can view the *Type* of attachment, as well as associated events. Click the Event ID to open the **Issue Details** of that specific event.

## [Maximum Attachment Size](https://docs.sentry.io/platforms/unity/enriching-events/attachments.md#maximum-attachment-size)

The maximum size for each attachment is set on `SentryOptions.MaxAttachmentSize`.

The scale is bytes and the default is `20 MiB`. Please also check the [maximum attachment size of Relay](https://docs.sentry.io/product/relay/options.md) to make sure your attachments don't get discarded there.

```csharp
// Add this to the SDK initialization callback
options.MaxAttachmentSize = 5 * 1024 * 1024; // 5 MiB
```
