NAME
Net::Google::Drive::Simple::Mirror - Locally mirror a Google Drive folder structure
SYNOPSIS
use Net::Google::Drive::Simple::Mirror;
# requires a ~/.google-drive.yml file containing an access token,
# see documentation of Net::Google::Drive::Simple
my $google_docs = Net::Google::Drive::Simple::Mirror->new(
remote_root => '/folder/on/google/docs',
local_root => 'local/folder',
export_format => ['opendocument', 'html'],
);
$google_docs->mirror();
DESCRIPTION
Net::Google::Drive::Simple::Mirror allows you to locally mirror a folder structure from Google Drive.
GETTING STARTED
For setting up your access token see the documentation of Net::Google::Drive::Simple.
METHODS
new()
-
Creates a helper object to mirror a remote folder to a local folder.
Parameters:
remote_root: folder on your Google Docs account. See "CAVEATS" below.
local_root: local folder to put the mirrored files in.
export_format: anonymous array containing your preferred export formats. Google Doc files may be exported to several formats. To get an idea of available formats, check 'exportLinks()' on a Google Drive Document or Spreadsheet, e.g.
my $gd = Net::Google::Drive::Simple->new(); # 'Simple' not 'Mirror' my $children = $gd->children( '/path/to/folder/on/google/drive' ); for my $child ( @$children ) { if ($child->can( 'exportLinks' )){ foreach my $type (keys %{$child->exportLinks()}){ print "$type"; } } }
Now, specify strings that your preferred types match against. The default is ['opendocument', 'html']
download_condition: reference to a sub that takes the remote file name and the local file name as parameters. Returns true or false. The standard implementation is: # XXX put _should_download() here.
force: download all files and replace local copies.
mirror()
-
Recursively mirrors Google Drive folder to local folder.
CAVEATS
At the moment, remote_root must not contain slashes in the file names of its folders.
'Folder/Containing/Letters A/B'
Because folder "Letters A/B" contains a slash:
Folder
`--Containing
`--Letters A/B
This will be resolved to:
Folder
`--Containing
`--Letters A
`--B
The remote_root 'Example/root' may contain folders and files with slashes. These get replaced with underscores in the local file system.
remote_root = 'Example/root';
Example
`--root
`--Letters A/B
(Net::Google::Drive::Simple::Mirror uses folder ID's as soon as it has found the remote_root and does not depend on folder file names.)