【计划昵称全网统一,代码随想随记,知乎无法立即修改,,】
微信公众号:leetcode_algos_life,代码随想随记
小红书:412408155
CSDN:https://blog.csdn.net/woai8339?type=blog ,代码随想随记
GitHub: https://github.com/riverind
抖音【暂未开始,计划开始】:tian72530,代码随想随记
知乎【暂未开始,计划开始】:happy001
假设读取oss上的文件路径是:
oss://path1/path2/path3/file_name
oss上传文件保存路径是
oss://path1/save_path2/save_path3/save_file_name
同一个
oss://path1/
来保障同一个bucket,便于oss操作。
auth = oss2.Auth(accessKeyId, accessKeySecret)
bucket_name = "path1"
oss_file_path = "path2/path3/file_name"
bucket = oss2.Bucket(oss2.Auth(accessKeyId, accessKeySecret), endpoint, bucket_name)
local_save_file_path="本地保存文件的地址"(带文件名,比如,./local/save_file_name)
bucket.get_object_to_file(oss_file_path, local_save_file_path)
oss_save_file_bucket_name = "save_path2/save_path3/"
oss_upload_file_path = oss_save_file_bucket_name + save_file_name
bucket.put_object_from_file(oss_upload_file_path, 本地文件地址)