Skip to content

dobachi/PubNubExample

Repository files navigation

PubNub Example

Prerequisite

  • CentOS7+
  • Python3.8+

Preparation

  • Install pyenv and Python 3.8.10
  • Create venv environment
  • Install requirements

pyenv

Please refer https://github.com/pyenv/pyenv

$ pyenv install 3.8.10

venv

Please refer https://docs.python.org/3/library/venv.html

$ python -m venv venv
$ . ./venv/bin/activate

install requirements

(venv)$ pip install -r requirements.txt

File Transfer Example

This example sends a JPEG image file to PubNub service, and receive the data from the service and open it as a image.

I used PIL to process images.

Sample codes

  • file_pub.py
    • This sends a file
  • file_sub.py
    • This receives a file
  • file_list.py
    • This lists files stored in the PubNub service

Create param.sh

Create the param.sh to register environmental variables for PubNub keys. param.sh is listed in .gitignore file to prevent accidents.

export PUBNUB_PUBKEY=pub-xxxxxx
export PUBNUB_SUBKEY=sub-xxxxxx

Execute param.sh

(venv)$ . param.sh

Send file

(venv)$ python file_pub.py

List file

(venv)$ python file_list.py

Receive and open file

(venv)$ python file_sub.py

This sample code uses PIL to open JPG data.

Messaging

This project includes sample codes: pub.py and sub.py

This are based on the official document's sample codes. Please refer the documents for use.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages