Search code examples
htmlcssgoogle-cloud-storagemime-typescontent-type

Google Cloud Storage seeing incorrect content type on my static files


My google cloud storage browser is seeing the incorrect content-type on all of my static files (css, js, jpg, etc.) and this is causing a mime type error when serving these files which causes my website to not apply my css styles. Why is this happening and how can I fix this? I am linking my static files correctly and with specifying the correct content-type, but this error is still happening.

<link rel="stylesheet" type="text/css" media="screen,print" href="index_files/index.css" />
<script type="text/javascript" src="index_files/index.js"></script>

As you can see in the following images, google cloud storage is seeing these static files with content-type application/octet-stream when it should be seeing them as text/css and text/javascript.

enter image description here enter image description here

UPDATE

The files are uploaded manually to the bucket.


Solution

  • You will have to manually edit the content type in the console. The instructions are in the documentation:

    1. Open the Cloud Storage browser in the Google Cloud Console.

    2. In the list of buckets, click on the name of the bucket that contains the desired object, and navigate to the object.

    3. Certain pieces of object metadata, such as the object's size and storage class, are displayed along with the object's name.

    4. Click the more actions menu () associated with the object.

    5. Click Edit metadata. The overlay window that appears shows the current values for the object's editable metadata.