Bae.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. if ( ! defined('BASE_PATH')) exit('No direct script access allowed');
  3. class StorageHandle{
  4. public $instance;
  5. public $domain;
  6. public function __construct(){
  7. $this->domain = DOMAIN;
  8. require dirname(__FILE__).'/bcs/bcs.class.php';
  9. $this->instance = new BaiduBCS();
  10. }
  11. public function exists($filename){
  12. return $this->instance->is_object_exist($this->domain,$this->get_file($filename));
  13. }
  14. //这里是效率瓶颈啊!!
  15. public function read($filename){
  16. return $this->instance->get_object($this->domain,$this->get_file($filename));
  17. }
  18. public function write($name,$content){
  19. return $this->instance->create_object_by_content($this->domain,$this->get_file($name),$content);
  20. }
  21. public function url($name){
  22. //return $this->instance->getUrl($this->domain,$this->get_file($name));
  23. return 'http://bcs.duapp.com/'.$this->domain.$this->get_file($name);
  24. }
  25. public function error(){
  26. return false;
  27. }
  28. public function delete($name){
  29. return $this->instance->delete_object($this->domain,$this->get_file($name));
  30. }
  31. private function get_file($name){
  32. return '/'.ltrim($name,'/');
  33. }
  34. }