About M4A audio files
An MP4 file with only an audio track, usually AAC. Apple software uses audio/x-m4a; the registered type is audio/mp4. Browsers play both, and for upload filters it is worth accepting both.
Other types seen for these files:
audio/x-m4a
,
audio/m4a
. Accept them when reading uploads, but send audio/mp4 yourself.
File signature
M4A files start with "ftypM4A " at byte 4. The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .m4a with the right Content-Type
Content-Type: audio/mp4
audio/mp4 m4a;
AddType audio/mp4 .m4a
@m4a path *.m4a
header @m4a Content-Type "audio/mp4"
curl -sI https://example.com/file.m4a | grep -i '^content-type'
# Content-Type: audio/mp4
Set the type in code
res.set('Content-Type', 'audio/mp4');
// Or make the browser download it:
res.attachment('file.m4a');
import mimetypes
mimetypes.add_type('audio/mp4', '.m4a') # if your system doesn't know it
mimetypes.guess_type('file.m4a')[0] # 'audio/mp4'
mime.AddExtensionType(".m4a", "audio/mp4")
w.Header().Set("Content-Type", "audio/mp4")
Accept .m4a uploads
<input type="file" accept=".m4a,audio/mp4">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
More audio
.wav , .ogg , .flac . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .m4a files?
audio/mp4. You may also see audio/x-m4a, audio/m4a, which are older or unofficial; send audio/mp4. The full header is "Content-Type: audio/mp4".
Why does my server send the wrong Content-Type for .m4a?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .m4a is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is M4A?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. M4A files start with "ftypM4A " at byte 4. The MIME type lookup on this site reads them for you when you drop a file on it.