Skip to content

Commit e556b7f

Browse files
Sebastian Molendapubnub-release-bot
andauthored
Additional example (#194)
* Additional example * ENV key names fixed * PubNub SDK v8.1.0 release. --------- Co-authored-by: PubNub Release Bot <[email protected]>
1 parent c8bf260 commit e556b7f

File tree

5 files changed

+74
-6
lines changed

5 files changed

+74
-6
lines changed

.pubnub.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: python
2-
version: 8.0.0
2+
version: 8.1.0
33
schema: 1
44
scm: github.com/pubnub/python
55
sdks:
@@ -18,7 +18,7 @@ sdks:
1818
distributions:
1919
- distribution-type: library
2020
distribution-repository: package
21-
package-name: pubnub-8.0.0
21+
package-name: pubnub-8.1.0
2222
location: https://pypi.org/project/pubnub/
2323
supported-platforms:
2424
supported-operating-systems:
@@ -97,8 +97,8 @@ sdks:
9797
-
9898
distribution-type: library
9999
distribution-repository: git release
100-
package-name: pubnub-8.0.0
101-
location: https://github.com/pubnub/python/releases/download/v8.0.0/pubnub-8.0.0.tar.gz
100+
package-name: pubnub-8.1.0
101+
location: https://github.com/pubnub/python/releases/download/v8.1.0/pubnub-8.1.0.tar.gz
102102
supported-platforms:
103103
supported-operating-systems:
104104
Linux:
@@ -169,6 +169,15 @@ sdks:
169169
license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt
170170
is-required: Required
171171
changelog:
172+
- date: 2024-08-13
173+
version: v8.1.0
174+
changes:
175+
- type: feature
176+
text: "Option to lock PNConfiguration mutability. Note that mutable config will be deprecated in future major releases."
177+
- type: bug
178+
text: "Fix for routing crypto module if custom one was defined."
179+
- type: improvement
180+
text: "Additional Examples."
172181
- date: 2024-05-09
173182
version: v8.0.0
174183
changes:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## v8.1.0
2+
August 13 2024
3+
4+
#### Added
5+
- Option to lock PNConfiguration mutability. Note that mutable config will be deprecated in future major releases.
6+
7+
#### Fixed
8+
- Fix for routing crypto module if custom one was defined.
9+
10+
#### Modified
11+
- Additional Examples.
12+
113
## v8.0.0
214
May 09 2024
315

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import os
2+
3+
4+
from pubnub.pubnub_asyncio import PubNubAsyncio
5+
from pubnub.pnconfiguration import PNConfiguration
6+
7+
8+
config = PNConfiguration()
9+
config.publish_key = os.environ.get('PUBLISH_KEY', 'demo')
10+
config.subscribe_request_timeout = 10
11+
config.subscribe_key = os.environ.get('SUBSCRIBE_KEY', 'demo')
12+
config.enable_subscribe = False
13+
config.uuid = 'example'
14+
15+
channel = 'file-channel'
16+
pubnub = PubNubAsyncio(config)
17+
sample_path = f"{os.getcwd()}/examples/native_sync/sample.gif"
18+
19+
20+
def callback(response, *args):
21+
print(f"Sent file: {response.result.name} with id: {response.result.file_id},"
22+
f" at timestamp: {response.result.timestamp}")
23+
24+
25+
with open(sample_path, 'rb') as sample_file:
26+
sample_file.seek(0)
27+
pubnub.send_file() \
28+
.channel(channel) \
29+
.file_name("sample.gif") \
30+
.message({"test_message": "test"}) \
31+
.file_object(sample_file) \
32+
.pn_async(callback)
33+
34+
file_list_response = pubnub.list_files().channel(channel).sync()
35+
print(f"Found {len(file_list_response.result.data)} files:")
36+
37+
for pos in file_list_response.result.data:
38+
print(f" {pos['name']} with id: {pos['id']}")
39+
ext = pos['name'].replace('sample', '')
40+
download_url = pubnub.get_file_url().channel(channel).file_id(pos['id']).file_name(pos['name']).sync()
41+
print(f' Download url: {download_url.result.file_url}')
42+
download_file = pubnub.download_file().channel(channel).file_id(pos['id']).file_name(pos['name']).sync()
43+
fw = open(f"{os.getcwd()}/examples/native_sync/out-{pos['id']}{ext}", 'wb')
44+
fw.write(download_file.result.data)
45+
print(f" file saved as {os.getcwd()}/examples/native_sync/out-{pos['id']}{ext}\n")
46+
pubnub.delete_file().channel(channel).file_id(pos['id']).file_name(pos['name']).sync()
47+
print(' File deleted from storage')

pubnub/pubnub_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
class PubNubCore:
9292
"""A base class for PubNub Python API implementations"""
93-
SDK_VERSION = "8.0.0"
93+
SDK_VERSION = "8.1.0"
9494
SDK_NAME = "PubNub-Python"
9595

9696
TIMESTAMP_DIVIDER = 1000

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='pubnub',
5-
version='8.0.0',
5+
version='8.1.0',
66
description='PubNub Real-time push service in the cloud',
77
author='PubNub',
88
author_email='[email protected]',

0 commit comments

Comments
 (0)