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


PHP Package::from_upload方法代码示例

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


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

示例1: upload

 /**
  * This handles uploads to a persions channel
  * Need file posted as 'file' and the has poster as 'hash'
  */
 public function upload()
 {
     switch ($this->format) {
         case 'xml':
             try {
                 $package = Package::from_upload(array('file' => $_FILES['file']['tmp_name'], 'sig' => $_POST['signatureBase64'], 'user' => $this->user), true);
                 if ($package->saved) {
                     echo 'Package uploaded succesfuly!';
                 }
             } catch (Exception $e) {
                 $this->header("HTTP/1.0 500 Internal Server Error", 500);
                 echo $e->getMessage();
             }
             $this->has_rendered = true;
             break;
         default:
             if ($_SESSION['upload_key'] !== $_POST['upload_key']) {
                 Nimble::flash('notice', 'Invalid Upload Key');
                 $this->redirect_to(url_for('LandingController', 'user_index', $this->user->username));
             }
             unset($_SESSION['upload_key']);
             try {
                 $package = Package::from_upload(array('file' => $_FILES['file']['tmp_name'], 'user' => $this->user));
                 if ($package->saved) {
                     $this->redirect_to(url_for('LandingController', 'user_index', $this->user->username));
                 }
             } catch (Exception $e) {
                 Nimble::flash('notice', $e->getMessage());
                 $this->redirect_to(url_for('ChannelController', 'upload'));
             }
             break;
     }
 }
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:37,代码来源:channel_controller.php

示例2: create_package

 public static function create_package()
 {
     $user = User::find_by_username('bob');
     $file = FileUtils::join(NIMBLE_ROOT, 'test', 'data', 'bobs_other_package-0.0.1.tgz');
     $package = Package::from_upload(array('file' => $file, 'user' => $user));
     foreach (User::_find('all') as $user) {
         $raiting = '0.' . $user->id;
         PackageRating::_create(array('user_id' => $user->id, 'package_id' => $package->id, 'rating' => (double) $raiting));
     }
 }
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:10,代码来源:story_helper.php

示例3: testUploadFailbadSig

 public function testUploadFailbadSig()
 {
     $localfile = FileUtils::join(NIMBLE_ROOT, 'test', 'data', 'joes_other_package-1.0.4.tgz');
     $sig = PackageVerifyTest::calculatePackageSignature($localfile);
     $user = User::find_by_username('joe');
     try {
         $p = Package::from_upload(array('file' => $localfile, 'sig' => $sig, 'user' => $user), true);
     } catch (NimbleException $e) {
         $this->assertEquals("Invalid package signature", $e->getMessage());
     }
 }
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:11,代码来源:FileUploadTest.php

示例4: create_package

 public static function create_package()
 {
     $user = User::find_by_username('bob');
     $file = FileUtils::join(NIMBLE_ROOT, 'test', 'data', 'bobs_other_package-0.0.1.tgz');
     $pp = Package::from_upload(array('file' => $file, 'user' => $user));
     $p = Package::update($pp->id, array('url' => 'http://jetviper21.com'));
 }
开发者ID:xetorthio,项目名称:pearfarm_channel_server,代码行数:7,代码来源:story_helper.php


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