Skip to content

Commit

Permalink
fix(async_owo.py): update for latest aiohttp
Browse files Browse the repository at this point in the history
The reason for the `aiohttp2` file existing is now redundant (aio-libs/aiohttp#916 got merged), so migrated to use regular aiohttp `MultipartWriter`.
  • Loading branch information
Ovyerus committed Feb 27, 2019
1 parent 508745b commit 54e46c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
36 changes: 0 additions & 36 deletions owo/aiohttp2.py

This file was deleted.

8 changes: 4 additions & 4 deletions owo/async_owo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import os.path as osp

from .utils import check_size, BASE_URL, MAX_FILES,\
UPLOAD_PATH, SHORTEN_PATH, UPLOAD_STANDARD,\
Expand All @@ -14,7 +15,6 @@ def async_upload_files(key, *files, **kwargs):
"is {}".format(MAX_FILES))

try:
from . import aiohttp2
import aiohttp
except ImportError:
raise ImportError("Please install the `aiohttp` module "
Expand All @@ -25,14 +25,14 @@ def async_upload_files(key, *files, **kwargs):
for file in files:
check_size(file)

with aiohttp2.MultipartWriter('form-data') as mp:
with aiohttp.MultipartWriter('form-data') as mp:
for file in files:
part = mp.append(open(file, "rb"))
part.set_content_disposition(
'form-data',
should_quote=False,
quote_fields=False,
name='files[]',
filename=file.lower()
filename=osp.basename(file).lower() # Errors without basename
)

session = aiohttp.ClientSession(loop=loop)
Expand Down

0 comments on commit 54e46c7

Please sign in to comment.