create a picture with picamera and upload it to nextcloud [raspberrypi]

based on:
https://github.com/owncloud/pyocclient

setup your cameramodule:
https://fredfire1.wordpress.com/2015/02/13/setup-raspberry-pi-camera-module-raspberrypi/

install picamera and nextcloudclient:
sudo apt install python-picamera python-pip -y
sudo pip install --upgrade pip
sudo pip install pyocclient

create a python script to create pic and upload it to nextcloud:
nano sharepic.py

#change the following lines to use the script:
#line 12 to your nextcloud domain
#line 13 to your username and password
#line 17 to your password to be able to download the file from public

import owncloud
import time
import picamera

camera = picamera.PiCamera()
camera.capture('picture.jpg')
oc = owncloud.Client('http://domain.tld/owncloud')
oc.login('user', 'password')
dt = str(time.strftime("%Y-%m-%d--%H-%M-%S"))
newname = 'pic_'+dt+'.jpg'
oc.put_file('Photos/'+newname, 'picture.jpg')
link_info = oc.share_file_with_link('Photos/'+newname, password="MyPasswordForThePublicFile")
print "Here is your link: "+ link_info.get_link()

to run the python script:
python sharepic.py

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s