You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,33 @@ service.terminate()
125
125
```
126
126
127
127
128
+
# Send attachement (screenshots)
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
+
128
155
# Copyright Notice
129
156
130
157
Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
0 commit comments