#!/usr/local/bin/perl -w
use strict;

use Net::Google::Drive::Simple;
use Log::Log4perl qw(:easy);
use Pod::Usage;

my ( $file, $dir ) = @ARGV;

if ( !$file ) {
    pod2usage("No file given for upload.");

if ( !-f $file ) {
    pod2usage("No such file: $file");

if ( !defined $dir ) {
    pod2usage("No Google Drive destination directory given.");


my $gd = Net::Google::Drive::Simple->new();

my ( $children, $parent ) =
  $gd->children( $dir, { maxResults => 1 } );

if ( !$parent ) {
    LOGDIE "Can't find remote directory $dir. Does it exist?";

$gd->file_upload( $file, $parent )
  or LOGDIE "Upload failed: $!";


=head1 NAME

    file-upload - Upload a file into a Google Drive directory


    file-upload local-file google-drive-dir


C<file-upload> uploads a given files to Google Drive, and puts
it into the destination directory specified.


  $ google-drive-upsync my.txt /stuff/txtfiles


Copyright 2014 by Mike Schilli, all rights reserved.
This program is free software, you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 AUTHOR

2014, Mike Schilli <cpan@perlmeister.com>