Skip to content

Commit 9f7d182

Browse files
author
Dzmitry Humianiuk
authored
Update README.md
1 parent 6455069 commit 9f7d182

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,33 @@ service.terminate()
125125
```
126126

127127

128+
# Send attachement
129+
130+
[python-client](https://github.com/reportportal/client-Python/blob/64550693ec9c198b439f8f6e8b23413812d9adf1/reportportal_client/service.py#L259) uses `request` library for working with RP and the same semantics to work with attachments (data).
131+
132+
There are two ways to pass data as attachment:
133+
134+
### Case 1 - pass file-like object
135+
```
136+
with open(screenshot_file_path, "rb") as image_file:
137+
rp_logger.info("Some Text Here",
138+
attachment={"name": "test_name_screenshot.png",
139+
"data": image_file,
140+
"mime": "image/png"})
141+
```
142+
143+
### Case 2 - pass file content itself (like you did)
144+
```
145+
with open(screenshot_file_path, "rb") as image_file:
146+
file_data = image_file.read()
147+
148+
rp_logger.info("Some Text Here",
149+
attachment={"name": "test_name_screenshot.png",
150+
"data": file_data,
151+
"mime": "image/png"})
152+
```
153+
154+
128155
# Copyright Notice
129156

130157
Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)

0 commit comments

Comments
 (0)