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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:38:10
Script start
Timing: Jan 18 2025 19:38:10
Module start 'layout'
Timing: Jan 18 2025 19:38:10
Module start 'content'
Timing: Jan 18 2025 19:38:10
Module end 'content'
Timing: Jan 18 2025 19:38:10
Script end

Main resources:

Total runtime0.6124 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 588.0469152.6406
Module start 'layout' 0.00470.0034 740.687539.4766
Module start 'content' 0.00810.6027 780.1641539.5000
Module end 'content' 0.61080.0015 1,319.664112.4375
Script end 0.6123  1,332.1016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.5014160.0002
Check MTime0.00130.2053160.0001
Mysql Total
Database connection0.00050.078910.0005
Mysqli_queries0.568692.8556600.0095
Looping result0.00050.0845580.0000
Template Total0.586595.820.2933
Template load0.00190.311720.0010
Template processing0.584695.466220.2923
Template load and register function0.00020.037710.0002
states
state_id_array0.00070.108310.0007
state_identifier_array0.00070.108020.0003
Override
Cache load0.00150.2481170.0001
Sytem overhead
Fetch class attribute can translate value0.00060.096520.0003
Fetch class attribute name0.00100.166650.0002
XML
Image XML parsing0.00060.105520.0003
class_abstraction
Instantiating content class attribute0.00000.002160.0000
General
dbfile0.00080.1347170.0000
String conversion0.00000.001540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs