# How to customize MIME media type emitted for certain attachments?

**URL:** https://meta.discourse.org/t/how-to-customize-mime-media-type-emitted-for-certain-attachments/282111
**Category:** Self-hosting
**Created:** [October 13, 2023, 6:03am UTC](https://meta.discourse.org/t/how-to-customize-mime-media-type-emitted-for-certain-attachments/282111 "2023-10-13T06:03:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xyzzy](https://avatars.discourse-cdn.com/v4/letter/x/e36b37/32.png) [@xyzzy](https://meta.discourse.org/u/xyzzy)
#### Post date: [October 13, 2023, 6:03am UTC](https://meta.discourse.org/t/how-to-customize-mime-media-type-emitted-for-certain-attachments/282111/1 "2023-10-13T06:03:36Z")

</div>

I have some users that wish to attach some files with uncommon file extensions to their posts. The files are basically text files so I’d like Discourse’s NGINX web server to emit the MIME media type “text/plain” when users download these files from Discourse.

Predictably, NGINX doesn’t recognize these uncommon file extensions. As a result, it currenlty emits “application/octet-stream” for these files.

I successfully updated the NGINX config to instruct it to use “text/plain” for these extensions but it still insists on using “application/octet-stream” when the users download the files from the posts.

Here’s what I did (the file extensions in this example are “.foo” and “.bar”):

1. sudo vi /var/discourse/containers/app.yml  
In the “run” section, just before the “End of custom commands” echo statement, added:

```plaintext
  - replace:
      filename: /etc/nginx/mime.types
      from: "txt;"
      to: "txt foo bar;"

```

1. cd /var/discourse
2. sudo ./launcher rebuild app

I’ve “bashed” into the container and verified the NGINX file was updated correctly from

```plaintext
text/plain txt;

```

to

```plaintext
text/plain txt foo bar;

```

What am I doing wrong?

I also tried using the “replace” mechanism to update the “types” section within /etc/nginx/conf.d/discourse.conf but that didn’t work either.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![xyzzy](https://avatars.discourse-cdn.com/v4/letter/x/e36b37/32.png) [@xyzzy](https://meta.discourse.org/u/xyzzy)
#### Post date: [October 26, 2023, 4:51am UTC](https://meta.discourse.org/t/how-to-customize-mime-media-type-emitted-for-certain-attachments/282111/2 "2023-10-26T04:51:21Z")

</div>

Hi everyone…does anyone have any ideas why this isn’t working?

Thanks!
