예제 #1
0
 /**
  * 移动文件到目标位置
  * @param string $opath 被移动的文件路径
  * @param string $path 目标位置(可能是同一api内或跨api,这两种情况分开处理)
  * @return icosdatas
  */
 public function CopyTo($opath, $path, $iscopy)
 {
     $oarr = self::parsePath($opath);
     $arr = IO::parsePath($path);
     $data = self::getMeta($opath);
     switch ($data['type']) {
         case 'folder':
             //创建目录
             if ($re = IO::CreateFolder($path, $data['name'])) {
                 $data['newdata'] = $re['icoarr'];
                 $data['success'] = true;
                 $contents = self::listFiles($opath);
                 foreach ($contents as $key => $value) {
                     $data['contents'][$key] = self::CopyTo($value['path'], $re['folderarr']['path']);
                 }
             }
             break;
         default:
             if ($re = IO::multiUpload($opath, $path, $data['name'])) {
                 if ($re['error']) {
                     $data['success'] = $re['error'];
                 } else {
                     $data['newdata'] = $re;
                     $data['success'] = true;
                 }
             }
     }
     return $data;
 }
예제 #2
0
 public function getFolderInfo($path, $position = '', $zip)
 {
     static $data = array();
     try {
         $arr = IO::parsePath($path);
         $pcs = self::init($path, 1);
         if (is_array($pcs) && $pcs['error']) {
             return $pcs;
         }
         $meta = self::getMeta($path);
         switch ($meta['type']) {
             case 'folder':
                 $position .= $meta['name'] . '/';
                 $contents = self::listFiles($path);
                 foreach ($contents as $key => $value) {
                     self::getFolderInfo($value['path'], $position, $zip);
                 }
                 break;
             default:
                 $meta['url'] = self::getStream($meta['path']);
                 $meta['position'] = $position . $meta['name'];
                 //$data[$meta['icoid']]=$meta;
                 $zip->addLargeFile(fopen($meta['url'], 'rb'), $meta['position'], $meta['dateline']);
         }
     } catch (Exception $e) {
         //var_dump($e);
         $data['error'] = $e->getMessage();
         return $data;
     }
     //return $data;
 }
예제 #3
0
 /**
  * 移动文件到目标位置
  * @param string $opath 被移动的文件路径
  * @param string $path 目标位置(可能是同一api内或跨api,这两种情况分开处理)
  * @return icosdatas
  */
 public function CopyTo($opath, $path, $iscopy)
 {
     static $i = 0;
     $i++;
     $oarr = self::parsePath($opath);
     $arr = IO::parsePath($path);
     $jss = self::init($opath);
     if (is_array($jss) && $jss['error']) {
         return $jss;
     }
     try {
         $data = self::getMeta($opath);
         switch ($data['type']) {
             case 'folder':
                 //创建目录
                 //exit($arr['path'].'===='.$data['name']);
                 if ($re = IO::CreateFolder($path, $data['name'])) {
                     if (isset($re['error'])) {
                         $data['success'] = $arr['error'];
                     } else {
                         $data['newdata'] = $re['icoarr'];
                         $data['success'] = true;
                         //echo $opath.'<br>';
                         $contents = self::listFilesAll($jss, $opath);
                         $value = array();
                         foreach ($contents as $key => $value) {
                             if ($value['path'] != $opath) {
                                 $data['contents'][$key] = self::CopyTo($value['path'], $re['folderarr']['path']);
                             }
                             $value = array();
                         }
                     }
                 } else {
                     $data['success'] = 'create folder failure';
                 }
                 break;
             default:
                 /*if($arr['bz']==$oarr['bz']){//同一个api时
                 			$arr=self::parsePath($path.$data['name']);
                 			$response=$jss->copy_object($oarr['bucket'],$oarr['object'],$arr['bucket'],$arr['object']);
                 			if(!$response->is_ok()){
                 				$data['success']=$response->status;
                 			}
                 			$meta=array(
                 						'Key'=>$arr['object'],
                 						'Size'=>$data['size'],
                 						'LastModified'=>$response->header['date'],
                 						);
                 			$data['newdata']=self::_formatMeta($meta,$arr);
                 			
                 			$data['success']=true;
                 		}else{*/
                 if ($re = IO::multiUpload($opath, $path, $data['name'])) {
                     if ($re['error']) {
                         $data['success'] = $re['error'];
                     } else {
                         $data['newdata'] = $re;
                         $data['success'] = true;
                     }
                 }
                 //}
                 break;
         }
         //	}
     } catch (Exception $e) {
         //var_dump($e);
         $data['success'] = $e->getMessage();
         return $data;
     }
     return $data;
 }