[sync] upload driver changed to s3

This commit is contained in:
tmshv committed 2019-05-29 23:06:57 +03:00
1 parent dbadbdafc3
commit 1bca661e13
4 files changed
+46 -54

No files matched your search

+2 -7
View File
@@ -18,10 +18,6 @@ logger = logging.getLogger(settings.name + '.Image')
store = collection(settings.collection_images)
def get_upload_url(url):
return os.path.join(settings.image_url_upload, os.path.basename(url))
def default_url_factory(file, size, ext):
url = settings.image_url_base + '{}-{}{}'
return url.format(md5(file), size, ext.lower())
@@ -115,11 +111,10 @@ class Image(Model):
async def upload(self):
if self.data:
async def fn(i):
url = get_upload_url(i['url'])
file = i['file']
filename = os.path.basename(file)
logger.info('Uploading to {}'.format(url))
await request.upload(url, file)
await request.s3_put('images/'+filename, file)
await asyncio.wait([fn(i) for i in self.data.values()])