def create_Dir(bucket, dir_Name): client = pyharbor.get_client() ok, msg = client.bucket(bucket).dir().create_dir(dir_Name) # 或者 # ok, msg = client.create_dir(bucket_name='gggg', dir_name='u/rrth/testdir') if ok: print('创建成功:' + msg) else: print('创建失败:' + msg)
def main(): ## file1=open('./log.txt','a') ## time1=time.time() filename = src client = pyharbor.get_client() ok, offset, msg = client.bucket(dst).dir('').put_object(obj_name=filename, filename=filename) if os.path.getsize(filename) == offset: ## d="%d" %(time.time()-time1) print(filename+" "+'\n')
def create_dir(bucket, dir_path, dir_name): client = pyharbor.get_client() dir_path3 = dir_path[del_len:] dir_path1 = dir_path3.replace("\\", "/") ok, msg = client.bucket(bucket).dir(dir_path1).create_dir(dir_name) # 或者 # ok, msg = client.create_dir(bucket_name='gggg', dir_name='u/rrth/testdir') if ok: print('创建成功:' + msg) else: print('创建失败:' + msg)
def __init__(self, args): print('初始化文件系统, 示例把 / 映射到挂载目录') self.bucket_name = args.bucket_name self.test_sys_root = realpath('/') pyharbor.set_global_settings({ # 配置对象存储链接 'SCHEME': 'http', # 或'https', 默认'https' 'DOMAIN_NAME': 'obs.casearth.cn', # 默认 'obs.casearth.cn' 'ACCESS_KEY': args.access_key, 'SECRET_KEY': args.secret_key, }) self.harbor_client = pyharbor.get_client() self.rwlock = Lock()
import os import pyharbor # 配置 pyharbor.set_global_settings({ 'SCHEME': 'http', # 或'https', 默认'https' # 'DOMAIN_NAME': '10.0.86.213:8000', # 默认 'obs.casearth.cn' 'ACCESS_KEY': '3b03b89e44a411e98dfcc8000a00c8d4', 'SECRET_KEY': 'eeef1cb1f6839c071df44507243e957f1aa548a6', }) client = pyharbor.get_client() # 创建一个目录 # ok, msg = client.bucket('www').dir().create_dir('testdir') # 或者 ok, msg = client.create_dir(bucket_name='www', dir_name='testdir') if ok: print('创建成功:' + msg) else: print('创建失败:' + msg) # 上传一个文件 filename = './examples.py' # ok, offset, msg = client.bucket('www').dir('testdir').put_object(obj_name='examples.py', filename=filename) # 或者 ok, offset, msg = client.put_object(bucket_name='www', obj_name='testdir/examples.py', filename=filename) if os.path.getsize(filename) == offset: