#135 CSS files are uploaded with MIME type text/plain

Documentation
open
nobody
None
5
2013-09-02
2013-03-19
Colin Viebrock
No

When using s3cmd sync, and I'm syncing .css files, they are getting created with content-type of "text/plain" instead of "text/css".

This may be the case because the CSS files contain long lines, but I'm not sure.

Discussion

  • Michal Ludvig
    Michal Ludvig
    2013-03-19

    That's because your system mime config doesn't know about css files. S3cmd relies on that to identify the mime type, by itself it doesn't make any decisions about file types.

     
  • Colin Viebrock
    Colin Viebrock
    2013-03-19

    You're right: if I do file -i style.css, I get back text/plain; charset=us-ascii. Ditto for javascript files. This is despite having entries in /etc/mime.types for .css and .js files.

    I know I can override the mime-type for individual files with the --mime-type=MIME/TYPE option, but I am currently doing a sync that could include many files (some CSS, some JS, some images, etc.).

    So, is there a way for s3cmd to use the file extension to determine the mime-type, instead of the magic method?

     
  • radomir
    radomir
    2013-07-17

    I have the same issue and it's a real pain. It makes sync unusable for updating web sites, at least on Linux.

    Traditionally file name suffixes are ignored on Unix systems (by http://wiki.debian.org/MIME) so just relying on magic numbers mechanism gives inconsistent results for text-based file types.

    I really hope there's a way to make this work in s3cmd.