Yeh, off course. I wanted to do it last night but it was too late.
The end results so far is: In every minute I'm getting to my DropBox a snapshot on my driveway taking by my webcam. As I've dropbox on my smartphone it's a convenience way to keep track the images.
So far I did:
1. Installed the PHP curl as commented above.
2. Downloaded the PHP script DropboxUploader.php from:
https://github.com/jakajancar/DropboxUploader and putted it under /share/1000/fvdw/addons/.
Tip: I changed CURLOPT_SSL_VERIFYPEER to false to avoid ssl exception.
3. Wrote a simple script (UploadMotion2DropBox.php) to upload a file to the Dropbox and putted it under /share/1000/fvdw/addons/.
4. Configured motion to take a snapshot using the motion configuration.
5. Add a crone to upload the lastsnap.jpg took by motion every minute and save it w/timestamp (to keep older files):
- Code: Select all
*/1 * * * * php /share/1000/fvdw/addons/UploadMotion2DropBox.php
I'm intended to shape a bit the script. I'd happy to hear comments.
b.t.w I thought to a have an option to send email w/the last motion in case the cam spot a movement...see more here:
http://www.dropboxwiki.com/Dropbox_Addons#PHP_.C2.A0And off course thank you for your great product and helping me. :applause
UploadMotion2DropBox.php
- Code: Select all
<?php
/*******************************************************************************
* file: UploadMotion2DropBox.php
* description: script to upload file to DropBox
* notes:
*******************************************************************************/
// configuration
$email = "Your email";
$password = "Your passwd";
// miscellaneous
$verbose = true ;
// file name + path
$file_name = "/share/1000/motion-webcam/snapshot/lastsnap.jpg" ;
$remote_name = null ;
$remote_dir = '/' ; // root by default
//require 'DropboxUploader.php';
require_once('DropboxUploader.php');
if( !file_exists($file_name) ) {
echo "ERROR: {$file_name} is not found on the filesystem\n" ;
exit( 1 ) ;
} else {
//$timestamp = time() ;
$remote_name = sprintf( "%s.%s",
//pathinfo($file_name, PATHINFO_FILENAME),
date("Ymd_His", time() - (10 * 3600)), //Convert UTC to PST
pathinfo($file_name, PATHINFO_EXTENSION)
);
echo "> Remote Name: {$remote_name}\n" ;
$remote_dir = sprintf( "%s/%s", "Motion" , date("D", (time() - (10 * 3600)))) ;
echo "> Remote Dir: {$remote_dir}\n" ;
}
$file_size = filesize( $file_name ) ;
if( $verbose ) { echo "> uploading {$remote_name} to {$remote_dir}\n" ; }
if( $verbose ) { echo "> file size: " . (string)($file_size / pow(1024, 2)) . "MB\n" ; }
try {
$uploader = new DropboxUploader($email, $password);
$uploader->upload($file_name, $remote_dir, $remote_name );
if( $verbose ) { echo "\n> all done!\n" ; }
} catch(Exception $e) {
echo "> ERROR: {$e->getMessage()}\n" ;
exit( 1 ) ;
}
// we made it
exit( 0 ) ;
?>