diff --git a/multipart/README.md b/multipart/README.md index 0da2dbf8..5eb57b38 100644 --- a/multipart/README.md +++ b/multipart/README.md @@ -12,13 +12,14 @@ cargo run (or ``cargo watch -x run``) # Started http server: 127.0.0.1:8080 ``` -### client +### browser -- ``pip install aiohttp`` -- ``python client.py`` +- go to ``http://localhost:8080`` +- upload file +- you should see the action reflected in server console + +### client (optional) + +- ``./client.sh`` - you must see in server console multipart fields -if ubuntu : - -- ``pip3 install aiohttp`` -- ``python3 client.py`` diff --git a/multipart/client.py b/multipart/client.py deleted file mode 100644 index d82c54dd..00000000 --- a/multipart/client.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 - -# This script could be used for actix-web multipart example test -# just start server and run client.py - -import asyncio -import aiohttp - -async def req1(): - with aiohttp.MultipartWriter() as writer: - writer.append('test') - writer.append_json({'passed': True}) - - resp = await aiohttp.ClientSession().request( - "post", 'http://localhost:8080/', - data=writer, headers=writer.headers) - print(resp) - assert 200 == resp.status - - -async def req2(): - with aiohttp.MultipartWriter() as writer: - writer.append('test') - writer.append_json({'passed': True}) - writer.append(open('src/main.rs')) - - resp = await aiohttp.ClientSession().request( - "post", 'http://localhost:8080/', - data=writer, headers=writer.headers) - print(resp) - assert 200 == resp.status - - -loop = asyncio.get_event_loop() -loop.run_until_complete(req1()) -loop.run_until_complete(req2()) diff --git a/multipart/client.sh b/multipart/client.sh new file mode 100755 index 00000000..10d82343 --- /dev/null +++ b/multipart/client.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +function SubmitFile () { + curl -X POST \ + -H "Content-Type: multipart/related" \ + --form "data=@example.png;type=image/png" http://localhost:8080 +} + +SubmitFile & SubmitFile & SubmitFile & +SubmitFile & SubmitFile & SubmitFile & +SubmitFile & SubmitFile & SubmitFile diff --git a/multipart/example.png b/multipart/example.png new file mode 100644 index 00000000..284b8a2f --- /dev/null +++ b/multipart/example.png @@ -0,0 +1,5 @@ +------------------------------4ebf00fbcf09 +Content-Disposition: form-data; name="example" + +test +------------------------------4ebf00fbcf09--