Skip to content

Commit 64d6cd5

Browse files
authored
Merge pull request #55 from livechat/Fix-file-upload
Fix `upload_file` methods
2 parents 05face3 + 8d8d9a0 commit 64d6cd5

File tree

7 files changed

+88
-127
lines changed

7 files changed

+88
-127
lines changed

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [pending] - TBA
5+
6+
### Changed
7+
8+
- Fixed methods for uploading files.
9+
- Renamed `reorder_auto_access` to `update_auto_access`
10+
411
## [0.1.8] - 2021-10-21
512

613
### Added

docs/agent_web.html

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -511,26 +511,21 @@ <h1 class="title">Module <code>client</code></h1>
511511

512512
def upload_file(self,
513513
file: typing.BinaryIO = None,
514-
payload: dict = None,
515514
headers: dict = None) -&gt; httpx.Response:
516515
&#39;&#39;&#39; Uploads a file to the server as a temporary file. It returns a URL that expires
517516
after 24 hours unless the URL is used in `send_event`.
518517

519518
Args:
520519
file (typing.BinaryIO): File-like object with file to upload (Maximum size: 10MB).
521-
payload (dict): Custom payload to be used as request&#39;s data.
522-
It overrides all other parameters provided for the method.
523520
headers (dict): Custom headers to be used with session headers.
524521
They will be merged with session-level values that are set,
525522
however, these method-level parameters will not be persisted across requests.
526523

527524
Returns:
528525
httpx.Response: The Response object from `httpx` library,
529526
which contains a server’s response to an HTTP request. &#39;&#39;&#39;
530-
if payload is None:
531-
payload = prepare_payload(locals())
532527
return self.session.post(f&#39;{self.api_url}/upload_file&#39;,
533-
json=payload,
528+
content=file.read(),
534529
headers=headers)
535530

536531
def send_rich_message_postback(self,
@@ -2722,26 +2717,21 @@ <h3>Inherited members</h3>
27222717

27232718
def upload_file(self,
27242719
file: typing.BinaryIO = None,
2725-
payload: dict = None,
27262720
headers: dict = None) -&gt; httpx.Response:
27272721
&#39;&#39;&#39; Uploads a file to the server as a temporary file. It returns a URL that expires
27282722
after 24 hours unless the URL is used in `send_event`.
27292723

27302724
Args:
27312725
file (typing.BinaryIO): File-like object with file to upload (Maximum size: 10MB).
2732-
payload (dict): Custom payload to be used as request&#39;s data.
2733-
It overrides all other parameters provided for the method.
27342726
headers (dict): Custom headers to be used with session headers.
27352727
They will be merged with session-level values that are set,
27362728
however, these method-level parameters will not be persisted across requests.
27372729

27382730
Returns:
27392731
httpx.Response: The Response object from `httpx` library,
27402732
which contains a server’s response to an HTTP request. &#39;&#39;&#39;
2741-
if payload is None:
2742-
payload = prepare_payload(locals())
27432733
return self.session.post(f&#39;{self.api_url}/upload_file&#39;,
2744-
json=payload,
2734+
content=file.read(),
27452735
headers=headers)
27462736

27472737
def send_rich_message_postback(self,
@@ -5581,7 +5571,7 @@ <h2 id="returns">Returns</h2>
55815571
</details>
55825572
</dd>
55835573
<dt id="client.AgentWebInterface.upload_file"><code class="name flex">
5584-
<span>def <span class="ident">upload_file</span></span>(<span>self, file: typing.BinaryIO = None, payload: dict = None, headers: dict = None) ‑> httpx.Response</span>
5574+
<span>def <span class="ident">upload_file</span></span>(<span>self, file: typing.BinaryIO = None, headers: dict = None) ‑> httpx.Response</span>
55855575
</code></dt>
55865576
<dd>
55875577
<div class="desc"><p>Uploads a file to the server as a temporary file. It returns a URL that expires
@@ -5590,9 +5580,6 @@ <h2 id="args">Args</h2>
55905580
<dl>
55915581
<dt><strong><code>file</code></strong> :&ensp;<code>typing.BinaryIO</code></dt>
55925582
<dd>File-like object with file to upload (Maximum size: 10MB).</dd>
5593-
<dt><strong><code>payload</code></strong> :&ensp;<code>dict</code></dt>
5594-
<dd>Custom payload to be used as request's data.
5595-
It overrides all other parameters provided for the method.</dd>
55965583
<dt><strong><code>headers</code></strong> :&ensp;<code>dict</code></dt>
55975584
<dd>Custom headers to be used with session headers.
55985585
They will be merged with session-level values that are set,
@@ -5610,26 +5597,21 @@ <h2 id="returns">Returns</h2>
56105597
</summary>
56115598
<pre><code class="python">def upload_file(self,
56125599
file: typing.BinaryIO = None,
5613-
payload: dict = None,
56145600
headers: dict = None) -&gt; httpx.Response:
56155601
&#39;&#39;&#39; Uploads a file to the server as a temporary file. It returns a URL that expires
56165602
after 24 hours unless the URL is used in `send_event`.
56175603

56185604
Args:
56195605
file (typing.BinaryIO): File-like object with file to upload (Maximum size: 10MB).
5620-
payload (dict): Custom payload to be used as request&#39;s data.
5621-
It overrides all other parameters provided for the method.
56225606
headers (dict): Custom headers to be used with session headers.
56235607
They will be merged with session-level values that are set,
56245608
however, these method-level parameters will not be persisted across requests.
56255609

56265610
Returns:
56275611
httpx.Response: The Response object from `httpx` library,
56285612
which contains a server’s response to an HTTP request. &#39;&#39;&#39;
5629-
if payload is None:
5630-
payload = prepare_payload(locals())
56315613
return self.session.post(f&#39;{self.api_url}/upload_file&#39;,
5632-
json=payload,
5614+
content=file.read(),
56335615
headers=headers)</code></pre>
56345616
</details>
56355617
</dd>

0 commit comments

Comments
 (0)