Forums / Developer / Set mime type of binary files programaticly

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Set mime type of binary files programaticly

Author Message

Dominik Pich

Monday 03 May 2004 7:03:38 am

How can I set the mime type of binary files programaticly?
Thanks

Jan Borsodi

Monday 10 May 2004 11:53:42 pm

Do you mean the binary file datatype?
Are you doing this in an import or in another setting?

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Dominik Pich

Tuesday 11 May 2004 12:47:20 am

I want to do this during import of a class with a binary file as attribute.
I uploaded a pdf to go with the class and need to set its mime type to 'application/pdf'.

Jan Borsodi

Wednesday 12 May 2004 4:37:04 am

Try something like this:

$binaryfile =& $attribute->content();
if ( is_object( $binaryFile ) )
{
    $binaryFile->setAttribute( 'mime_type', 'application/pdf' );
    $binaryFile->store();
}

This assumes that <i>$attribute</i> is an eZContentObjectAttribute.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq