
alnino2005
New User
Dec 2, 2012, 11:10 AM
Post #1 of 1
(3275 views)
|
WebService::Dropbox and Furl?
|
Can't Post
|
|
I am having some very strange trouble uploading files using WebService::Dropbox. My program takes a URL as an argument, downloads it using getstore(), then transfers it to the dropbox root using files_put(). Below is a list of URLs where this process works flawlessly every time. I have also included a list where the files download well, but are not transferred to dropbox at all. The program times out after 30sec and sends this error:
C:\drop>drop.pl http://alanhelton.com/wp-content/uploads/2012/04/webdev-160x145.png Unexpected EOF while reading response header at C:/Perl/site/lib/WebService/Drop box.pm line 381. Dropbox.pm at 381: my ($minor_version, $code, $msg, $headers, $body) = $self->furl->request(%$args); Perhaps this has something to do with furl? The module is installed. Should I reinstall? It's just so strange that some of these files work but others don't. Working: http://perlmonks.org/images/monkpics/pater_hat_sm.gif http://farm9.staticflickr.com/8199/8232259823_9dcdb73e1f.jpg Non working: http://farm9.staticflickr.com/8068/8231401634_fbca41a7b5.jpg http://24.media.tumblr.com/avatar_c3855683af46_96.png http://912freedomlibrary.org/custom-1/Moby+Dick+by+Herman+Melville.pdf http://alanhelton.com/wp-content/uploads/2012/04/webdev-160x145.png http://alanhelton.com/wp-content/uploads/2011/04/break1.jpg DROP.PL (You must add your own account's key and secret after finishing the OAuth.)
use WebService::Dropbox; use LWP::Simple; use strict; use warnings; my $url = $ARGV[0]; my @filenametmp = split('\/', $url); my $file_name = @filenametmp[scalar(@filenametmp)-1]; my $dropbox = WebService::Dropbox->new({ key => 'key', # App Key secret => 'secret' # App Secret }); #-- fetch the zip and save it my $status = getstore($url, "upload\\".$file_name); sleep(2); if (-e "upload\\".$file_name) { #print "\nSaved ".$file_name." as ".$ufn." correctly\n"; # upload # https://www.dropbox.com/developers/reference/api#files_put my $access_token = 'token'; my $access_secret = 'secret'; # get access token if (!$access_token or !$access_secret) { my $url = $dropbox->login or die $dropbox->error; warn "Please Access URL and press Enter: $url"; <STDIN>; $dropbox->auth or die $dropbox->error; warn "access_token: " . $dropbox->access_token; warn "access_secret: " . $dropbox->access_secret; } else { $dropbox->access_token($access_token); $dropbox->access_secret($access_secret); } my $info = $dropbox->account_info or die $dropbox->error; my $fh_put = IO::File->new("upload\\".$file_name); print "Uploading '".$file_name."'\n"; $dropbox->files_put($file_name, $fh_put, { overwrite => 0 }) or die $dropbox->error; $fh_put->close; print "DONE"; } else { print "error downloading file: $status\n"; }
|