[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 ?

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 31 2025 06:25:06
Script start
Timing: Jan 31 2025 06:25:06
Module start 'layout'
Timing: Jan 31 2025 06:25:06
Module start 'content'
Timing: Jan 31 2025 06:25:06
Module end 'content'
Timing: Jan 31 2025 06:25:06
Script end

Main resources:

Total runtime0.0193 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.0313151.1953
Module start 'layout' 0.00690.0019 739.226636.6172
Module start 'content' 0.00880.0079 775.843894.1406
Module end 'content' 0.01660.0026 869.984433.9922
Script end 0.0193  903.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003015.4882140.0002
Check MTime0.00136.5420140.0001
Mysql Total
Database connection0.00105.397410.0010
Mysqli_queries0.002311.834430.0008
Looping result0.00000.061710.0000
Template Total0.00147.110.0014
Template load0.00105.024410.0010
Template processing0.00041.994210.0004
Override
Cache load0.00073.578510.0007
General
dbfile0.00031.402780.0000
String conversion0.00000.043240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

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

Time used to render debug report: 0.0001 secs