About iCalendar files
Used for “Add to calendar” links and calendar subscriptions. With the right type, phones and desktop mail apps offer to add the event; a calendar feed that should stay in sync is linked with webcal:// instead of https://. Lines must end in CRLF, and long lines are folded at 75 bytes.
File signature
ICS files start with "BEGIN:VCALENDAR". 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 .ics with the right Content-Type
Content-Type: text/calendar; charset=utf-8
text/calendar ics ifb;
AddType text/calendar .ics .ifb
AddCharset UTF-8 .ics .ifb
@ics path *.ics *.ifb
header @ics Content-Type "text/calendar; charset=utf-8"
curl -sI https://example.com/file.ics | grep -i '^content-type'
# Content-Type: text/calendar; charset=utf-8
Set the type in code
res.set('Content-Type', 'text/calendar; charset=utf-8');
import mimetypes
mimetypes.add_type('text/calendar', '.ics') # if your system doesn't know it
mimetypes.guess_type('file.ics')[0] # 'text/calendar'
mime.AddExtensionType(".ics", "text/calendar; charset=utf-8")
w.Header().Set("Content-Type", "text/calendar; charset=utf-8")
Accept .ics uploads
<input type="file" accept=".ics,.ifb,text/calendar">
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 data and text
.tsv , .md , .ndjson , .jsonld , .xml , .yaml , .geojson , .sql . 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 .ics files?
text/calendar. It is a text format, so add the character set: "Content-Type: text/calendar; charset=utf-8".
Why does my server send the wrong Content-Type for .ics?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .ics 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 ICS?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. ICS files start with "BEGIN:VCALENDAR". The MIME type lookup on this site reads them for you when you drop a file on it.