What is MIME type "text/swig"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

The MIME type text/swig marks files written in SWIG’s interface language. These files contain instructions that let the SWIG tool generate wrappers. They bridge C/C++ libraries with higher-level languages like Python, Java, or others.

Files with this MIME type are typically saved with the file extension SWG.

For more details on SWIG and its usage, check the SWIG official website.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/swig    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/swig">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/swig');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What is the primary use of the text/swig MIME type?

The text/swig MIME type is used for SWIG interface files, which act as a bridge between C/C++ libraries and high-level languages like Python or Java. These files usually have the .swg extension and contain the definitions required to generate wrapper code.

How do I open or edit a file served as text/swig?

Since these are plain text files, you can open them in any standard text editor or Integrated Development Environment (IDE). Popular choices include Visual Studio Code, Sublime Text, or command-line editors like Vim, which often have syntax highlighting plugins for SWIG.

How do I configure Apache to serve .swg files with this MIME type?

To associate the extension with this MIME type in Apache, add the following line to your .htaccess file or main configuration: AddType text/swig .swg. This ensures the server explicitly identifies the file content rather than defaulting to text/plain.

What is the Nginx configuration for text/swig?

For Nginx, you should update your mime.types file or the types block within your nginx.conf. Add the line text/swig swg; to ensure the server sends the correct Content-Type header for these interface files.

Why does my browser download .swg files instead of displaying them?

Browsers do not have built-in rendering engines for SWIG syntax, so they often treat unknown text types as downloads. To force the browser to display the code, you can configure your server to send the header Content-Type: text/plain for these files, or install a browser extension for syntax highlighting.

Are text/swig files executable?

No, files with the text/swig MIME type are source code files, not executables. They must be processed by the SWIG tool to generate wrapper code (in C, C++, or the target language), which is then compiled or interpreted.

Is text/swig a standard IANA MIME type?

This is generally considered a non-standard or vendor-specific media type. While useful for internal server configuration and identification, many systems may simply classify these files as text/plain or application/octet-stream if the specific type is not manually configured.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.