Content-type of mp3s stored in lfs

I’ve recently enabled Large Media, as my site is storing several mp3 files.

Since doing so, I note the content-type used when these are served is application/octet-stream, whereas previously it was audio/mpeg.

Unfortunately, this prevents them from being played by Twilio, which seems to be very particular about needing the correct content-type. This worked prior to this change.

I tried adding the following netlify.toml file, to no effect. Either I’ve done something wrong here, or it would seem that its headers entries don’t apply to Large Media files.

[[headers]]
  for = "*.mp3"
  [headers.values]
    content-type = "audio/mpeg"

[[headers]]  
  for = "*.pdf"
  [headers.values]
    content-type = "application/pdf"

Is there any way I can change the content-type used to serve these mp3 files, or do I need to request for lfs to be disabled?

I wonder is this content-type issue what the docs are alluding to where they state:

Netlify Large Media is not suitable for streaming audio or video files. However, storing these assets for download should work well.

I found this post, which seems fairly relevant. Unfortunately, the solution there involved updating the version of git-lfs to at least 2.5.1. I can confirm that my git-lfs version is 2.9.2, and that git config lfs.contenttype is true. (This appears to be behaving as if it actually false, per the git lfs docs.)

In case its of use, I attach the output when I try to re-push a file to git lfs.

GIT_TRACE=1 GIT_TRANSFER_TRACE=1 GIT_CURL_VERBOSE=1 git lfs push origin --object-id 6088342491b4fa8deeab5b7e2b5b607647def3b7894b7b25245e66da94f1b197

00:00:20.147503 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
00:00:20.149504 git.c:703               trace: exec: git-lfs push origin --object-id 6088342491b4fa8deeab5b7e2b5b607647def3b7894b7b25245e66da94f1b197
00:00:20.149504 run-command.c:662       trace: run_command: git-lfs push origin --object-id 6088342491b4fa8deeab5b7e2b5b607647def3b7894b7b25245e66da94f1b197
00:00:20.174511 trace git-lfs: exec: git 'version'
00:00:20.207517 trace git-lfs: exec: git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'rev-parse' 'HEAD' '--symbolic-full-name' 'HEAD'
00:00:20.328544 trace git-lfs: exec: git 'config' '-l'
00:00:20.344548 trace git-lfs: exec: git 'config' '-l' '-f' 'C:\Users\ftwin\Documents\Projects\bvp\.lfsconfig'
00:00:20.360552 trace git-lfs: tq: running as batched queue, batch size of 100
00:00:20.361557 trace git-lfs: tq: sending batch of size 1
00:00:20.361557 trace git-lfs: api: batch 1 files
00:00:20.361557 trace git-lfs: creds: git credential fill ("https", "cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app", "")
00:00:20.370554 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
00:00:20.371554 git.c:439               trace: built-in: git credential fill
00:00:20.372554 run-command.c:662       trace: run_command: 'git credential-netlify get'
00:00:20.400560 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
00:00:20.401561 git.c:703               trace: exec: git-credential-netlify get
00:00:20.401561 run-command.c:662       trace: run_command: git-credential-netlify get
time="2020-11-24T00:00:20Z" level=debug msg="Initializing Netlify credential helper" args="[git-credential-netlify get]"
time="2020-11-24T00:00:20Z" level=debug msg="Git input received" host=cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app protocol=https
time="2020-11-24T00:00:20Z" level=debug msg="Writing output data" host=cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app password="_K8gYN****************" protocol=https username=access-token
00:00:20.804652 trace git-lfs: Filled credentials for https://cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app/.netlify/large-media
00:00:20.810653 trace git-lfs: HTTP: POST https://cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app/.netlify/large-media/objects/batch
> POST /.netlify/large-media/objects/batch HTTP/1.1
> Host: cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app
> Accept: application/vnd.git-lfs+json; charset=utf-8
> Authorization: Basic * * * * *
> Content-Length: 204
> Content-Type: application/vnd.git-lfs+json; charset=utf-8
> User-Agent: git-lfs/2.9.2 (GitHub; windows amd64; go 1.12.7; git 0274d856)
>
{"operation":"upload","objects":[{"oid":"6088342491b4fa8deeab5b7e2b5b607647def3b7894b7b25245e66da94f1b197","size":53662747}],"transfers":["lfs-standalone-file","basic"],"ref":{"name":"refs/heads/master"}}00:00:21.505810 trace git-lfs: HTTP: 200


< HTTP/2.0 200 OK
< Content-Length: 144
< Age: 1
< Alt-Svc: clear
< Content-Type: application/vnd.git-lfs+json
< Date: Tue, 24 Nov 2020 00:00:22 GMT
< Server: Netlify
< Via: 1.1 google
< X-Nf-Request-Id: c7b4c924-159f-4fcf-8c3f-e2aff760eaca-26182771
<
00:00:21.508811 trace git-lfs: creds: git credential approve ("https", "cfdb2a7b-b1d3-4dee-ad78-02642c39b2d4.netlify.app", "")
00:00:21.517813 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
00:00:21.518813 git.c:439               trace: built-in: git credential approve
00:00:21.519813 run-command.c:662       trace: run_command: 'git credential-netlify store'
00:00:21.547819 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
00:00:21.548820 git.c:703               trace: exec: git-credential-netlify store
00:00:21.548820 run-command.c:662       trace: run_command: git-credential-netlify store
time="2020-11-24T00:00:21Z" level=debug msg="Initializing Netlify credential helper" args="[git-credential-netlify store]"
00:00:21.583828 run-command.c:662       trace: run_command: 'git credential-manager store'
00:00:21.610834 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
00:00:21.611834 git.c:703               trace: exec: git-credential-manager store
00:00:21.611834 run-command.c:662       trace: run_command: git-credential-manager store
00:00:21.963914 trace git-lfs: HTTP: {"transfer":"basic","objects":[{"oid":"6088342491b4fa8deeab5b7e2b5b607647def3b7894b7b25245e66da94f1b197","size":53662747,"authenticated":true}]}
{"transfer":"basic","objects":[{"oid":"6088342491b4fa8deeab5b7e2b5b607647def3b7894b7b25245e66da94f1b197","size":53662747,"authenticated":true}]}00:00:21.963914 trace git-lfs: tq: starting transfer adapter "basic"
00:00:21.963914 trace git-lfs: xfer: adapter "basic" Begin() with 8 workers
00:00:21.963914 trace git-lfs: xfer: adapter "basic" started
00:00:21.963914 trace git-lfs: xfer: adapter "basic" End()
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 1 starting
00:00:21.964914 trace git-lfs: xfer: adapter "basic" worker 1 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 3 starting
00:00:21.964914 trace git-lfs: xfer: adapter "basic" worker 3 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 6 starting
00:00:21.965914 trace git-lfs: xfer: adapter "basic" worker 6 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 2 starting
00:00:21.965914 trace git-lfs: xfer: adapter "basic" worker 2 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 4 starting
00:00:21.965914 trace git-lfs: xfer: adapter "basic" worker 4 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 7 starting
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 7 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 5 starting
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 5 waiting for Auth
00:00:21.963914 trace git-lfs: xfer: adapter "basic" worker 0 starting
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 0 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 6 auth signal received
00:00:21.967914 trace git-lfs: xfer: adapter "basic" worker 6 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 2 auth signal received
00:00:21.967914 trace git-lfs: xfer: adapter "basic" worker 2 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 5 auth signal received
00:00:21.967914 trace git-lfs: xfer: adapter "basic" worker 5 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 4 auth signal received
00:00:21.968914 trace git-lfs: xfer: adapter "basic" worker 4 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 7 auth signal received
00:00:21.968914 trace git-lfs: xfer: adapter "basic" worker 7 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 3 auth signal received
00:00:21.968914 trace git-lfs: xfer: adapter "basic" worker 3 stopping
00:00:21.966914 trace git-lfs: xfer: adapter "basic" worker 1 auth signal received
00:00:21.969915 trace git-lfs: xfer: adapter "basic" worker 1 stopping
00:00:21.969915 trace git-lfs: xfer: adapter "basic" stopped
Uploading LFS objects: 100% (1/1), 54 MB | 0 B/s, done.
00:00:21.969915 trace git-lfs: filepathfilter: rewrite ".git" as "**/.git/**"
00:00:21.969915 trace git-lfs: filepathfilter: rewrite "**/.git" as "**/.git"
00:00:21.969915 trace git-lfs: filepathfilter: accepting "tmp"

I don’t see anything obvious in there myself.

I pushed a new mp3 file and could see the correct content-type in the trace output. So I thought I might simply re-push all the existing mp3 files. Unfortunately, it helpfully remembers the files and doesn’t need to resend them, even if I rename them.

I’ll have a go at either either tweaking all the mp3 files slightly, or using the bfg to remove them from the repository history and re-add them again.

Hi, @FTWinston. Have you tried requesting the new mp3s from the deployed site? Do they have the correct content type now?

If so, there is a way for us to update the other files to match so please let us know if the newer mp3s do work.

Hi @luke,

Yes, if I upload a new mp3 file and then request it over the web, it correctly gets the audio/mpeg content type.

If you’re able to correct the content-type of the existing mp3 files, that would be fantastic.

It seems that the content-types went wrong when converting the existing repo to use large media. I couldn’t say whether the problem was with netlify’s large media, git lfs, or something I did, but the last option is probably the most likely.

Thanks

I uploaded a new mp3 file using the Git Extensions GUI and it ended up still downloading as application/octet-stream.

I then modifed the mp3 and uploaded from the command line with verbose logging, and could see it sending a content type of audio/mpeg. Browsing to the file, then downloads it as audio/mpeg.

So I’ll just burn the GUI!

Hi, @FTWinston. Sorry about the delay as there has been some back and forth about how to fix this on our side.

There is a tool which can do this but I don’t personally have access to the permissions required to make it work.

It sounds like you also have a solution and that the issue is itself caused by the Git Extensions GUI. Do you still need the other MP3s to have their content type updated?

Hi @luke,

No, that’s fine. I’ve tweaked the remaining mp3s and pushed them to lfs with the correct content type.

Nothing else required here.

Thanks,
Winston