options = $options; try { $serviceConfig = new \Upyun\Config( $this->options['uss_service_name'], $this->options['uss_operator_name'], $this->options['uss_operator_pwd'] ); $this->uss = new \Upyun\Upyun($serviceConfig); } catch (\Exception $e) { $this->error = $e->getMessage(); } } /** * 创建文件 * * @param $pathname * @param $file * * @return bool */ public function create($pathname, $file) { try { $this->uss->write($pathname, fopen($file, 'r')); } catch (\Exception $e) { $this->error = $e->getMessage(); return false; } return true; } /** * 删除文件 * * @param $pathname * * @return bool */ public function delete($pathname) { try { $this->uss->delete($pathname); } catch (\Exception $e) { $this->error = $e->getMessage(); return false; } return true; } /** * 删除多个文件 * * @param array $list * @return bool|mixed */ public function deletes(array $list) { try { foreach ($list as $value) { if (is_string($value)) { // 异步删除 $this->uss->delete($value, true); } } } catch (\Exception $e) { $this->error = $e->getMessage(); return false; } return true; } public function getError() { return 'Uss:' . $this->error; } }