当前位置: 首页>>代码示例>>PHP>>正文


PHP FileList::createEntry方法代码示例

本文整理汇总了PHP中FileList::createEntry方法的典型用法代码示例。如果您正苦于以下问题:PHP FileList::createEntry方法的具体用法?PHP FileList::createEntry怎么用?PHP FileList::createEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileList的用法示例。


在下文中一共展示了FileList::createEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processQueue


//.........这里部分代码省略.........
                    //fixme: source & destination should not be able to be the same!
                    $dst_file = 'tmpfile.mp3';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                default:
                    die('unknown destination audio format: ' . $job['orderParams']);
            }
            echo 'Executing: ' . $c . "\n";
            $exec_time = exectime($c);
            echo 'Execution time: ' . shortTimePeriod($exec_time) . "\n";
            if (!file_exists($dst_file)) {
                echo '<b>FAILED - dst file ' . $dst_file . " dont exist!\n";
                break;
            }
            //FIXME: behöver inget rename-steg. kan skriva till rätt output fil i första steget
            rename($dst_file, $h->files->upload_dir . $newId);
            $h->files->updateFile($newId);
            markQueueCompleted($job['entryId'], $exec_time);
            break;
        case TASK_VIDEO_RECODE:
            echo "VIDEO RECODE:\n";
            $exec_start = microtime(true);
            if (convertVideo($job['referId'], $job['orderParams']) === false) {
                markQueue($job['entryId'], ORDER_FAILED);
            } else {
                markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
            }
            break;
        case TASK_FETCH:
            echo "FETCH CONTENT\n";
            $fileName = basename($job['orderParams']);
            //extract filename part of url, used as "filename" in database
            $http = new HttpClient($job['orderParams']);
            $http->getHead();
            if ($http->getStatus() != 200) {
                // retry in 20 seconds if file is not yet ready
                retryQueueEntry($job['entryId'], 20);
                break;
            }
            $newFileId = FileList::createEntry(FILETYPE_PROCESS, 0, 0, $fileName);
            $c = 'wget ' . escapeshellarg($job['orderParams']) . ' -O ' . FileInfo::getUploadPath($newFileId);
            echo "\$ " . $c . "\n";
            $retval = 0;
            $exec_time = exectime($c, $retval);
            if (!$retval) {
                //TODO: process html document for media links if it is a html document
                TaskQueue::markTaskCompleted($job['entryId'], $exec_time, $newFileId);
                FileInfo::updateData($newFileId);
            } else {
                //wget failed somehow, delay work for 1 minute
                retryQueueEntry($job['entryId'], 60);
                $files->deleteFile($newFileId, 0, true);
                //remove failed local file entry
            }
            break;
        case TASK_CONVERT_TO_DEFAULT:
            echo "CONVERT TO DEFAULT\n";
            //referId is entryId of previous proccess queue order
            $params = unserialize($job['orderParams']);
            $prev_job = TaskQueue::getEntry($job['referId']);
            if ($prev_job['orderStatus'] != ORDER_COMPLETED) {
                retryQueueEntry($job['entryId'], 60);
                break;
            }
            $file = $files->getFileInfo($prev_job['referId']);
            $exec_start = microtime(true);
            $newId = false;
            switch ($file['mediaType']) {
                case MEDIATYPE_VIDEO:
                    $newId = convertVideo($prev_job['referId'], $h->files->default_video, !empty($params['callback']) ? false : true, !empty($params['watermark']) ? $params['watermark'] : '');
                    break;
                case MEDIATYPE_AUDIO:
                    $newId = convertAudio($prev_job['referId'], $h->files->default_audio);
                    break;
                default:
                    echo "UNKNOWN MEDIA TYPE " . $file['mediaType'] . ", MIME TYPE " . $file['fileMime'] . ", CANNOT CONVERT MEDIA!!!\n";
                    break;
            }
            if (!$newId) {
                markQueue($job['entryId'], ORDER_FAILED);
                return false;
            }
            markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
            if (empty($params['callback'])) {
                break;
            }
            //'uri' isnt known before the new file is created so it is added at this point
            $uri = $config['core']['full_url'] . 'api/file.php?id=' . $newId;
            $params['callback'] .= (strpos($params['callback'], '?') !== false ? '&' : '?') . 'uri=' . urlencode($uri);
            $data = file_get_contents($params['callback']);
            echo "Performing callback: " . $params['callback'] . "\n\n";
            echo "Callback script returned:\n" . $data;
            storeCallbackData($job['entryId'], $data, $params);
            break;
        default:
            echo "Unknown ordertype: " . $job['orderType'] . "\n";
            d($job);
            die;
    }
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:101,代码来源:functions_process.php


注:本文中的FileList::createEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。