phpsdk上传文件到指定bucket的指定目录下
Rephpsdk上传文件到指定bucket的指定目录下
你目前可以自己改造一下SDK来实现该功能。如下
public function create_mtu_object_by_dir($bucket,$object/*新增object参数*/,$dir,$recursive = false,$exclude = '.|..|.svn',$options = null){
//options
$this->validate_options($options);
//bucket
$this->is_empty($bucket,OSS_BUCKET_IS_NOT_ALLOWED_EMPTY);
if($this->chk_chinese($dir)){
$dir = iconv('utf-8','gbk',$dir);
}
//判断是否目录
if(!is_dir($dir)){
throw new OSS_Exception($dir.' is not a directory...,pls check it');
}
$file_list_array = $this->read_dir($dir,$exclude,$recursive);
if(!$file_list_array){
throw new OSS_Exception($dir.' is empty...');
}
$index = 1;
foreach ($file_list_array as $item){
$options = array(
self::OSS_FILE_UPLOAD => $item['path'],
self::OSS_PART_SIZE => 5242880,
);
echo $index .'. ';
$response = $this->create_mpu_object($bucket, $object.’/’.$item['file'],$options); //这个位置文件名前添加object
if($response->isOK()){
echo 'Upload file {'.$item['path'].' } successful..\n';
}else{
echo 'Upload file {'.$item['path'].' } failed..\n';
continue;
}
}
}
赞0
踩0