File-Dropbox
view release on metacpan or search on metacpan
lib/File/Dropbox.pm view on Meta::CPAN
package File::Dropbox;
use strict;
use warnings;
use feature ':5.10';
use base qw{ Tie::Handle Exporter };
use Symbol;
use JSON;
use Errno qw{ ENOENT EISDIR EINVAL EPERM EACCES EAGAIN ECANCELED EFBIG };
use Fcntl qw{ SEEK_CUR SEEK_SET SEEK_END };
use Furl;
use IO::Socket::SSL;
use Net::DNS::Lite;
our $VERSION = 0.7;
our @EXPORT_OK = qw{ contents metadata putfile movefile copyfile createfolder deletefile };
my $hosts = {
content => 'api-content.dropbox.com',
api => 'api.dropbox.com',
};
my $version = 1;
my $header1 = join ', ',
'OAuth oauth_version="1.0"',
'oauth_signature_method="PLAINTEXT"',
'oauth_consumer_key="%s"',
'oauth_token="%s"',
'oauth_signature="%s&%s"';
my $header2 = 'Bearer %s';
sub new {
my $self = Symbol::gensym;
tie *$self, __PACKAGE__, my $this = { @_[1 .. @_ - 1] };
*$self = $this;
return $self;
} # new
sub TIEHANDLE {
my $self = bless $_[1], ref $_[0] || $_[0];
$self->{'chunk'} //= 4 << 20;
$self->{'root'} //= 'sandbox';
die 'Unexpected root value'
unless $self->{'root'} =~ m{^(?:drop|sand)box$};
$self->{'furl'} = Furl->new(
timeout => 10,
inet_aton => \&Net::DNS::Lite::inet_aton,
ssl_opts => {
SSL_verify_mode => SSL_VERIFY_PEER(),
},
%{ $self->{'furlopts'} //= {} },
);
$self->{'closed'} = 1;
$self->{'length'} = 0;
$self->{'position'} = 0;
$self->{'mode'} = '';
$self->{'buffer'} = '';
return $self;
} # TIEHANDLE
sub READ {
my ($self, undef, $length, $offset) = @_;
( run in 0.931 second using v1.01-cache-2.11-cpan-39bf76dae61 )