Skip to content
← Back to activity

Public problem

ocifs: setting Content-Type when writing a file to OCI Object Storage

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Writing a file to OCI Object Storage with ocifs gave no way to set the Content-Type on the new object: with fs.open("oci://bucket@namespace/prefix/hello.txt", 'w', autocommit=True) as f: f.write(...) stored the object without the right MIME type (visible in the OCI console), and passing contenttype to open() did not take effect. The SDK equivalent (putobject with content_type=...) worked, but ocifs did not honor the parameter.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The library was not wiring the content type through on file writes. Fixed in ocifs 1.3.1: the open() call now both guesses the content type from the file extension when you do not pass one, and honors an explicit content_type= parameter. Upgrade ocifs to 1.3.1 or later and write with:

with fs.open("oci://bucket@namespace/prefix/file.png", 'wb', autocommit=True, content_type='image/png') as f: f.write(data)

Omit content_type and ocifs sets the standard MIME mapping (text/plain for .txt, etc.) automatically.

Source: https://github.com/oracle/ocifs/issues/28

Source: https://github.com/oracle/ocifs/issues/28