Bae.php 1.1 KB

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