|
@@ -17,8 +17,7 @@ import tqdm
|
|
import urllib3
|
|
import urllib3
|
|
|
|
|
|
from utils.tools import *
|
|
from utils.tools import *
|
|
-from utils.aliyun import JyOssClient
|
|
|
|
-
|
|
|
|
|
|
+from utils.aliyun import AliYunService
|
|
|
|
|
|
|
|
|
|
urllib3.disable_warnings()
|
|
urllib3.disable_warnings()
|
|
@@ -42,7 +41,8 @@ class AttachmentDownloader:
|
|
self.dir_name = "file"
|
|
self.dir_name = "file"
|
|
|
|
|
|
self._max_retries = max_retries
|
|
self._max_retries = max_retries
|
|
- self._oss = JyOssClient()
|
|
|
|
|
|
+ # self._oss = JyOssClient()
|
|
|
|
+ self._oss = AliYunService()
|
|
|
|
|
|
def create_file(self, filename, filetype):
|
|
def create_file(self, filename, filetype):
|
|
os.makedirs(self.dir_name, mode=0o777, exist_ok=True)
|
|
os.makedirs(self.dir_name, mode=0o777, exist_ok=True)
|
|
@@ -212,7 +212,8 @@ class AttachmentDownloader:
|
|
attachment["fid"] = "{}.{}".format(fid, filetype)
|
|
attachment["fid"] = "{}.{}".format(fid, filetype)
|
|
attachment["size"] = self.getsize(stream)
|
|
attachment["size"] = self.getsize(stream)
|
|
attachment["url"] = "oss"
|
|
attachment["url"] = "oss"
|
|
- self._oss.upload("file", attachment["fid"], stream)
|
|
|
|
|
|
+ # self._oss.upload("file", attachment["fid"], stream)
|
|
|
|
+ self._oss.push_oss_from_stream(attachment["fid"], stream)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logger.error(
|
|
logger.error(
|
|
"[{}]上传失败,原因:{}".format(filename, type(e).__name__)
|
|
"[{}]上传失败,原因:{}".format(filename, type(e).__name__)
|
|
@@ -263,7 +264,8 @@ class AttachmentDownloader:
|
|
attachment["size"] = self.getsize(file)
|
|
attachment["size"] = self.getsize(file)
|
|
attachment["ftype"] = filetype
|
|
attachment["ftype"] = filetype
|
|
attachment["url"] = "oss"
|
|
attachment["url"] = "oss"
|
|
- self._oss.upload("file", attachment["fid"], stream)
|
|
|
|
|
|
+ # self._oss.upload("file", attachment["fid"], stream)
|
|
|
|
+ self._oss.push_oss_from_local(attachment["fid"], file)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logger.error(
|
|
logger.error(
|
|
"[{}]上传失败,原因:{}".format(filename, type(e).__name__)
|
|
"[{}]上传失败,原因:{}".format(filename, type(e).__name__)
|