Upload Files to Google Drive or Dropbox automatically

Upload Files to Google Drive or Dropbox automatically

Postby ronyronen » Sat Feb 16, 2013 5:40 pm

Hi there,

The webcam integration feature work great for me. However, I wanted to expand it and try to upload the images to my google drive hence to be able to access them from the internet.
I saw few topics related however all of them are using the cURL which is not installed on the nas. Do you happen to have cURL to put in the nas :?:

BTW, I installed Ubuntu 11.04 on VM and added a custom kernel w/the same version of the nas. But I didn't succeed to compile a cURL bin and used it on the nas. I guess Ubuntu uses difference shell...

Thank you.
I have the nwsp2 v14.
ronyronen
Donator VIP
Donator VIP
 
Posts: 10
Joined: Sun Dec 30, 2012 6:30 am

Re: Upload Files to Google Drive or Dropbox automatically

Postby fvdw » Sun Feb 17, 2013 7:52 am

I will have a look at it and compile it for you
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: Upload Files to Google Drive or Dropbox automatically

Postby fvdw » Sun Feb 17, 2013 8:27 am

attached a compiled version and it runs on the nwsp2

It can be installed as addon, see this topic for instruction to prepare the NAS for using addons
viewtopic.php?f=15&t=645

For this addons put the zip file in the addons folder and unpack it , then extract the tar file in the same folder

Let us know your experiences, seems an interesting program and we might add it to the standard applications in the firmware

addons-curl-7.29.0-17feb13.zip


below the configuration used for compile

Code: Select all
  curl version:     7.29.0
  Host setup:       armv5tel-unknown-linux-gnueabi
  Install prefix:   /usr/local
  Compiler:         gcc
  SSL support:      enabled (OpenSSL)
  SSH support:      no      (--with-libssh2)
  zlib support:     enabled
  krb4 support:     no      (--with-krb4*)
  GSSAPI support:   no      (--with-gssapi)
  SPNEGO support:   no      (--with-spnego)
  TLS-SRP support:  no      (--enable-tls-srp)
  resolver:         default (--enable-ares / --enable-threaded-resolver)
  ipv6 support:     enabled
  IDN support:      no      (--with-{libidn,winidn})
  Build libcurl:    Shared=yes, Static=yes
  Built-in manual:  no      (--enable-manual)
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     no
  LDAP support:     enabled (OpenLDAP)
  LDAPS support:    enabled
  RTSP support:     enabled
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMTP SMTPS TELNET TFTP

You do not have the required permissions to view the files attached to this post.
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: Upload Files to Google Drive or Dropbox automatically

Postby ronyronen » Mon Feb 18, 2013 3:27 am

Thanks for the quick response.
I'm newbie to this linux world but still wanted to give it a try. Apparently, the script to upload files needs the PHP+cURL as it uses curl_init and other functions.

The tutorial I'm following is: https://github.com/jakajancar/DropboxUploader
I was succeed to upload a file to my Dropbox from Ubuntu. However, when executing the same from the nas it gives an error.
When I search the web I find out that I need to PHP and cURL together: http://php.net/manual/en/book.curl.php

Thanks.
ronyronen
Donator VIP
Donator VIP
 
Posts: 10
Joined: Sun Dec 30, 2012 6:30 am

Re: Upload Files to Google Drive or Dropbox automatically

Postby fvdw » Mon Feb 18, 2013 6:46 pm

so you need the php curl extension. Also that is probably no problem.
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: Upload Files to Google Drive or Dropbox automatically

Postby fvdw » Mon Feb 18, 2013 9:20 pm

it was easier then I thought, attached the curl.so compiled for php.
curl-php-extension-18feb2013.zip

You need to install it in /usr/lib/php/extensions/
(don't forget to set it as executable, chmod 755 )

In /etc/php.ini you will need to add
Code: Select all
extension=curl.so

(at line 593)

Also you need to have libcurl installed as add on (the one I posted)
On my system php now mentions that curl is loaded

curl.JPG
You do not have the required permissions to view the files attached to this post.
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: Upload Files to Google Drive or Dropbox automatically

Postby ronyronen » Tue Feb 19, 2013 7:00 am

Thank you so match. It's now working for me. However, I needed to put the file under /usr/lib/php/extensions and not modules.
ronyronen
Donator VIP
Donator VIP
 
Posts: 10
Joined: Sun Dec 30, 2012 6:30 am

Re: Upload Files to Google Drive or Dropbox automatically

Postby fvdw » Tue Feb 19, 2013 12:15 pm

:thumbup

nice, indeed I meant extensions and not modules.

Can you post what you have done to use this feature ?
fvdw
Site Admin - expert
 
Posts: 13471
Joined: Tue Apr 12, 2011 2:30 pm
Location: Netherlands

Re: Upload Files to Google Drive or Dropbox automatically

Postby santa » Tue Feb 19, 2013 5:53 pm

nice ideea
I will try'it
santa
 

Re: Upload Files to Google Drive or Dropbox automatically

Postby ronyronen » Tue Feb 19, 2013 7:38 pm

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.A0

And 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 )  ;

?>
ronyronen
Donator VIP
Donator VIP
 
Posts: 10
Joined: Sun Dec 30, 2012 6:30 am


Return to Development

Who is online

Users browsing this forum: No registered users and 12 guests