Forums / Developer / [php] eZBinaryFileType

[php] eZBinaryFileType

Author Message

Rémy Limouzin

Monday 09 June 2008 8:14:00 am

<b>Hello every body!</b>

I have a problem with eZBinaryFileType (the datatype).
I look to create a file object in my extension to store à pdf.
My pdf was juste create on my server at : /home/usr23/

<i>Here the code where I create a new file object and store datas :</i>


<?php //IN a MODULE

define('PATH_PDF','/home/usr23/');
$filename = 'the_temp_name_of_my_file';

//father
$parentNodeID_file = 100;//my father

//class
$class_file = eZContentClass::fetchByIdentifier('file');
$contentObject_file = $class_file->instantiate(eZUser::currentUserID(),EZ_VERSION_STATUS_PUBLISHED);
$contentObject_file->store();

//assignment
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject_file->attribute( 'id' ),
                                                 'contentobject_version' => $contentObject_file->attribute( 'current_version' ),
                                                 'parent_node' => $parentNodeID_file, 
                                                 'is_main' => 1 ));
$nodeAssignment->store();

//version
$version_file =& $contentObject_file->version( 1 );
$version_file->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
$version_file->setAttribute( 'status', EZ_VERSION_STATUS_PUBLISHED );
$version_file->store();

//data
$data_map_file =& $contentObject_file->fetchDataMap();

$data_map_file['name']->fromString('filename');
$data_map_file['name']->store();
$data_map_file['description']->fromString('create : '.date('Y-m-d.H-i-s'));
$data_map_file['description']->store();
////////////////////////////////////////////////////////////////////////////////////////TEST
//~ here i found 2 functions how can work : 
 //~ - insertRegularFile()
 //~ - fromString() 
//~ fromString() call insertRegularFile()


$result=array();
//$data_map_file['file'] -> insertRegularFile($contentObject_file,$version_file,false,PATH_PDF.$filename,$result);

$data_map_file['file']->fromString($contentObject_file,PATH_PDF.$filename);


print($data_map_file['file']->toString());
////////////////////////////////////////////////////////////////////////////////////////TEST
$data_map_file['file']->store();

//publication
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject_file->attribute( 'id' ),'version' => 1) );	
    
?>

In the back-office:

If I use insertRegularFile() I obtain a file object how directly propose to download the file. And the file is corrupt. If I edit my object, the file attribute is empty.

If I use fromString() I obtain a file object with a normal comportment but the file stored is empty…..

Some one can help me?
Thanks.

Rémy Limouzin

Monday 09 June 2008 8:19:31 am

<b>Configuration: </b>
eZPublish version 3.10.0
Server LAMP
PDF created by FPDF (www.fpdf.org)

<b>NB:</b>
On my server, at /home/usr23/ezpublish/var/myssite/storage/original/application
PFDs created are good.

Rémy Limouzin

Thursday 12 June 2008 7:06:05 am

some one ?

Rémy Limouzin

Tuesday 19 August 2008 3:59:21 am

up !

I come back to my problem.
Some one ?

eZ debug

Timing: Jan 31 2025 04:15:56
Script start
Timing: Jan 31 2025 04:15:56
Module start 'content'
Timing: Jan 31 2025 04:15:56
Module end 'content'
Timing: Jan 31 2025 04:15:56
Script end

Main resources:

Total runtime0.1513 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 587.8281180.8438
Module start 'content' 0.00640.0067 768.671997.8516
Module end 'content' 0.01310.1381 866.5234529.2500
Script end 0.1512  1,395.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.4244200.0002
Check MTime0.00140.9211200.0001
Mysql Total
Database connection0.00100.657610.0010
Mysqli_queries0.099565.79101410.0007
Looping result0.00120.77011390.0000
Template Total0.137891.110.1378
Template load0.00080.520810.0008
Template processing0.137090.541910.1370
Override
Cache load0.00050.352410.0005
Sytem overhead
Fetch class attribute can translate value0.00090.570510.0009
XML
Image XML parsing0.00020.151310.0002
General
dbfile0.01107.2860200.0006
String conversion0.00000.003530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs