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


PHP Application::dataDir方法代码示例

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


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

示例1: file

 public function file(Silex\Application $app)
 {
     $request = new \Flow\Request();
     $chunkNumber = $request->getCurrentChunkNumber() ?: 0;
     $chunkSize = $request->getDefaultChunkSize() ?: 0;
     $totalSize = $request->getTotalSize() ?: 0;
     $identifier = $request->getIdentifier() ?: '';
     $filename = $request->getFileName() ?: '';
     $files = $request->getFile();
     if (!$files || !$files['size']) {
         utils::log('invalid_flow_request');
         return new Response('', Response::HTTP_OK, ['Content-Type' => 'text/plain']);
     }
     $original_filename = $files['name'];
     //['originalFilename'] ;
     $validation = $this->validateRequest($chunkNumber, $chunkSize, $totalSize, $identifier, $filename, $files['size']);
     if ($validation !== 'valid') {
         utils::log($validation);
         return new Response('', Response::HTTP_OK, ['Content-Type' => 'text/plain']);
     }
     $chunkFilename = $this->getChunkFilename($chunkNumber, $identifier);
     // Save the chunk
     //$fs =new Filesystem () ;
     //$fs->rename ($files ['tmp_name'], $chunkFilename, true) ;
     move_uploaded_file($files['tmp_name'], $chunkFilename);
     // Do we have all the chunks?
     $currentTestChunk = 1;
     //$numberOfChunks =max (intval (floor ($totalSize / ($chunkSize * 1.0))), 1) ;
     $numberOfChunks = $request->getTotalChunks();
     for (; $currentTestChunk <= $numberOfChunks; $currentTestChunk++) {
         if (!utils::realpath($this->getChunkFilename($currentTestChunk, $identifier))) {
             break;
         }
     }
     if ($currentTestChunk > $numberOfChunks) {
         // done
         utils::log("POST done {$original_filename} {$identifier}");
         $data = (object) array('key' => $identifier, 'name' => $original_filename, 'size' => $totalSize, 'bytesRead' => $totalSize, 'bytesPosted' => 0);
         $path = $app->dataDir("/{$identifier}.json");
         if (file_put_contents($path, json_encode($data)) === false) {
             utils::log("Could not save {$path}");
         }
         $path = $app->tmpDir("/{$original_filename}");
         $this->save($path, $request);
         // 				var st =fs.createWriteStream ('./tmp/' + original_filename)
         // 				.on ('finish', function () {}) ;
         // 				flow.write (identifier, st, {
         // 					end: true,
         // 					onDone: function () {
         // 						flow.clean (identifier) ;
         // 					}
         // 				}) ;
     } else {
         // partly_done
         utils::log("POST partly_done {$original_filename} {$identifier}");
     }
     //if ( ACCESS_CONTROLL_ALLOW_ORIGIN )
     //	return (new Response ('', Response::HTTP_OK, [ 'Access-Control-Allow-Origin' => '*', Content-Type' => 'text/plain' ])) ;
     return new Response('', Response::HTTP_OK, ['Content-Type' => 'text/plain']);
 }
开发者ID:cyrillef,项目名称:extract-php-view.and.data.api,代码行数:60,代码来源:LmvFile.php

示例2: dl

 public function dl(Silex\Application $app, $identifier, $fragment)
 {
     $bucket = lmv::getDefaultBucket();
     $path = $app->dataDir("/{$identifier}.resultdb.json", true);
     if (!$path) {
         return new Response('', Response::HTTP_NOT_FOUND, ['Content-Type' => 'text/plain']);
     }
     $content = file_get_contents($path);
     $data = json_decode($content);
     $guid = $data->urn;
     $urn = "urn:adsk.viewing:fs.file:{$guid}/output/{$fragment}";
     $lmv = new lmv($bucket);
     $response = $lmv->downloadItem($urn);
     if (is_int($reponse)) {
         return new Response('', Response::HTTP_NOT_FOUND, ['Content-Type' => 'text/plain']);
     }
     $filename = basename($fragment);
     return new Response($response, Response::HTTP_OK, ['Cache-Control' => 'private', 'Content-Type' => 'application/octet-stream', 'Content-Length' => strlen($response), 'Content-Disposition' => "attachment; filename=\"{$filename}\""]);
     // Send headers before outputting anything?
     //$response->sendHeaders () ;
 }
开发者ID:cyrillef,项目名称:extract-php-view.and.data.api,代码行数:21,代码来源:LmvResults.php

示例3: submitProject

 public function submitProject(Silex\Application $app, Request $request)
 {
     $bucket = lmv::getDefaultBucket();
     $policy = 'transient';
     $connections = json_decode($request->getContent());
     utils::log("master: {$connections->uniqueIdentifier}");
     // Save parameters for the translate process
     $path = $app->dataDir("/{$connections->uniqueIdentifier}.dependencies.json");
     if (file_put_contents($path, json_encode($connections)) === false) {
         utils::log('ERROR: project dependencies not saved :(');
         return new Response('', Response::HTTP_NOT_FOUND, ['Content-Type' => 'text/plain']);
     }
     $result = utils::executeScript("/translate.php lmv:translator {$connections->uniqueIdentifier}", true);
     if ($result === false) {
         return new Response('', Response::HTTP_INTERNAL_SERVER_ERROR, ['Content-Type' => 'text/plain']);
     }
     // We submitted, no clue if it was successful or if it will fail.
     $response = (object) array('status' => 'submitted');
     return new JsonResponse($response, Response::HTTP_OK);
     //- 202 Accepted
 }
开发者ID:cyrillef,项目名称:extract-php-view.and.data.api,代码行数:21,代码来源:LmvProjects.php


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