diff --git a/modules/xrowvideo/upload.php b/modules/xrowvideo/upload.php index 5b3a3ca..23fc08a 100644 --- a/modules/xrowvideo/upload.php +++ b/modules/xrowvideo/upload.php @@ -54,6 +54,7 @@ $async = true; } + if($fileHandler == "eZDFSFileHandler") { $nfs = true; @@ -205,7 +206,7 @@ * The directories will get deleted by xrowMedia->updateMediaInfo() * \_ eZDFSFileHandler->deleteLocal() * \_ eZClusterFileHandler::cleanupEmptyDirectories() - * if the local file was the only file inside that directory tree. + * if local file was the only file inside that directory tree. */ if (!file_exists(dirname($storeName))) { mkdir(dirname($storeName), 0777, true); @@ -213,15 +214,6 @@ rename($storeNameNFS, $storeName); - $contentObjectAttributeID = $attribute->attribute( 'id' ); - $version = $attribute->attribute( 'version' ); - - $binary = eZBinaryFile::create( $contentObjectAttributeID, $version ); - $binary->setAttribute( 'filename', basename( $storeName ) ); - $binary->setAttribute( 'original_filename', $fileName ); - $binary->setAttribute( 'mime_type', $mime['name'] ); - $binary->store(); - $fileHandler = eZClusterFileHandler::instance(); // fileStore() is slow with large files $fileHandler->fileStore( $storeName, 'binaryfile', false, $mime['name'] ); @@ -240,6 +232,18 @@ // Store the received file if its the last chunk or if the data was send via streaming if( (isset( $_REQUEST['chunk'] ) && $chunk == $targetchunk) || !isset( $_REQUEST['chunk'])) { + $db = eZDB::instance(); + $db->begin(); + $contentObjectAttributeID = $attribute->attribute( 'id' ); + $version = $attribute->attribute( 'version' ); + + $binary = eZBinaryFile::create( $contentObjectAttributeID, $version ); + $binary->setAttribute( 'filename', basename( $storeName ) ); + $binary->setAttribute( 'original_filename', $fileName ); + $binary->setAttribute( 'mime_type', $mime['name'] ); + $binary->store(); + $db->commit(); + // If AsyncFileTransfer is enabled perform the file processing asynchronous to prevent timeouts, otherwise just execute it if ($async) { // AsyncFileTransfer requires xrow mq-bundle installed and at least eZ 5.4 @@ -249,6 +253,7 @@ } else { $closure(); } + eZLog::write( gmdate( 'D, d M Y H:i:s', time() ) . " ObjectID #" . $obj->ID . " completed", "xrowvideo.log"); }