|
@@ -16,7 +16,7 @@ import urllib3
|
|
|
|
|
|
import feapder.utils.tools as tools
|
|
import feapder.utils.tools as tools
|
|
from feapder.utils.log import log as logger
|
|
from feapder.utils.log import log as logger
|
|
-from feapder.utils.oss import JyOssClient, OssBucketClient
|
|
|
|
|
|
+from feapder.utils.oss import JyOssClient
|
|
|
|
|
|
urllib3.disable_warnings()
|
|
urllib3.disable_warnings()
|
|
|
|
|
|
@@ -37,8 +37,7 @@ class Downloader:
|
|
|
|
|
|
def __init__(self):
|
|
def __init__(self):
|
|
self.dir_name = "file"
|
|
self.dir_name = "file"
|
|
- # self._oss = JyOssClient()
|
|
|
|
- self._bucket = OssBucketClient()
|
|
|
|
|
|
+ self._oss = JyOssClient()
|
|
|
|
|
|
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)
|
|
@@ -228,8 +227,7 @@ class Downloader:
|
|
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, gzip=gzip)
|
|
|
|
- self._bucket.put_object(attachment["fid"], stream)
|
|
|
|
|
|
+ self._oss.upload("file", attachment["fid"], stream, gzip=gzip)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logger.error(
|
|
logger.error(
|
|
"[{}]上传失败,原因:{}".format(filename, e.__class__.__name__)
|
|
"[{}]上传失败,原因:{}".format(filename, e.__class__.__name__)
|
|
@@ -266,8 +264,7 @@ class Downloader:
|
|
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, gzip=gzip)
|
|
|
|
- self._bucket.put_object_from_file(attachment["fid"], file)
|
|
|
|
|
|
+ self._oss.upload("file", attachment["fid"], stream, gzip=gzip)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logger.error(
|
|
logger.error(
|
|
"[{}]上传失败,原因:{}".format(filename, e.__class__.__name__)
|
|
"[{}]上传失败,原因:{}".format(filename, e.__class__.__name__)
|