コード例 #1
0
ファイル: FileTest.php プロジェクト: CFLOVEYR/hook
 public function testBase64Detect()
 {
     $base64_png = File::base64('data:image/png;base64,UftKpGMhKUvUQ5w');
     $this->assertTrue($base64_png[1] == "image/png");
     $this->assertTrue($base64_png[2] == "");
     $this->assertTrue($base64_png[3] == "UftKpGMhKUvUQ5w");
     $base64_jpg = File::base64('data:image/jpg;base64,UftKpGMhKUvUQ5w');
     $this->assertTrue($base64_jpg[1] == "image/jpg");
     $this->assertTrue($base64_jpg[2] == "");
     $this->assertTrue($base64_jpg[3] == "UftKpGMhKUvUQ5w");
     $base64_otf = File::base64('data:application/vnd.ms-opentype; charset=binary;base64,T1RUTwALAIAAAwAwQ');
     $this->assertTrue($base64_otf[1] == "application/vnd.ms-opentype");
     $this->assertTrue($base64_otf[2] == " charset=binary;");
     $this->assertTrue($base64_otf[3] == "T1RUTwALAIAAAwAwQ");
     $base64_otf2 = File::base64('data:application/vnd.ms-opentype;charset=binary;base64,T1RUTwALAIAAAwAwQ');
     $this->assertTrue($base64_otf2[1] == "application/vnd.ms-opentype");
     $this->assertTrue($base64_otf2[2] == "charset=binary;");
     $this->assertTrue($base64_otf2[3] == "T1RUTwALAIAAAwAwQ");
     $string1 = File::base64("this is just a plain string, not a base64,wathever.");
     $this->assertFalse($string1);
 }
コード例 #2
0
ファイル: Collection.php プロジェクト: CFLOVEYR/hook
 protected function uploadAttachedFiles()
 {
     foreach ($this->_attached_files as $field => $file) {
         $_file = File::create(array('file' => $file));
         $this->setAttribute($field, $_file->path);
         $this->setAttribute($field . '_id', $_file->_id);
     }
     $this->_attached_files = null;
 }
コード例 #3
0
ファイル: CollectionController.php プロジェクト: hyhyxu/hook
 public static function getData()
 {
     // TODO: refactoring
     if (Request::isPost()) {
         $data = Request::post('d', Request::post('data', Request::post()));
     } else {
         $data = Input::get('d', Input::get('data', Input::get()));
     }
     $attached_files = array();
     // Check for base64-encoded files
     foreach ($data as $key => $value) {
         if (Model\File::base64($value)) {
             $attached_files[$key] = $value;
         }
     }
     if (!empty($_FILES)) {
         $attached_files = array_merge($attached_files, $_FILES);
     }
     if (!empty($attached_files)) {
         $data[Model\Collection::ATTACHED_FILES] = $attached_files;
     }
     return $data;
 }
コード例 #4
0
 public function testStore()
 {
     $file = File::create(array('file' => 'data:text/plain;base64,' . base64_encode('Saving text file.')));
     $this->assertTrue(preg_match('/^http:\\/\\//', $file->path) == 1);
     $this->assertTrue($file->read() == "Saving text file.");
 }