使用需要提前安装 pip install oss2 模块
上传到目录时,存储到oss上key取目录内文件或者目录列表的相对路径:
如:D:/demo/ 文件夹,文件夹内有,dir1/f1, dir2/f2, f3这几个文件,则存储到oss上key取dir1/f1,dir2/f2,f3
# -*- coding: utf-8 -*-
# Author: tom
# Description: ali oss tool for upload local file or dir
# Date: 2020年8月24日
# Usage: python alioss_uploader.py D:\workspace\web "\\resources\\|\\WEB-INF\\|\\wx\\|.*.jsp|.*.swf", first arg is upload path, second arg is exclude pattern
import oss2
import os
import sys
import re
import logging
# import asyncio
from concurrent import futures
console_handler = logging.StreamHandler()
file_handler = logging.FileHandler(filename='./upload.log', mode='w')
log_format = '%(asctime)s %(threadName)s-%(thread)d %(levelname)s: %(message)s'
formatter = logging.Formatter(log_format)
logging.basicConfig(filename='./upload.log', filemode='w', format=log_format