Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^10: Combining File::Fetch with MySQL

by hippo (Bishop)
on Jul 25, 2022 at 15:47 UTC ( [id://11145716]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Combining Ffile:fetch with MySQL
in thread Combining Ffile:fetch with MySQL

my $where = $ff->fetch( to => '$path');

Again, you are enclosing a variable inside single quotes, so it won't be interpolated. Remove the quotes for more success.

Here is an SSCCE showing how to use File::Fetch successfully.

#!/usr/bin/env perl use strict; use warnings; use File::Fetch; use Test::More tests => 1; my $url = 'https://www.perlmonks.org/?part=1;displaytype=displaycode;n +ode_id=11145569;abspart=1'; my $ff = File::Fetch->new (uri => $url); my $loc = $ff->fetch (to => '/tmp/'); ok -f $loc, "Downloaded file to $loc";

Try examining the return value of fetch like this in your code to find the saved file.


🦛

Replies are listed 'Best First'.
Re^11: Combining File::Fetch with MySQL
by justin423 (Scribe) on Jul 25, 2022 at 16:58 UTC
    "Success"!!! ok, I got it to work for one file and when doing it for the 2nd file, it overwrote the first, because all the files are named "document.pdf". so I updated it to this, which isn't ideal. I would rather use the field document_id in the database instead of just getting back document0.pdf document1.pdf document2.pdf
    $i=0; while (my $ref = $query->fetchrow_hashref()) { print "url: $ref->{url}\n"; my $ff = File::Fetch->new(uri=>$ref->{url}); my $where = $ff->fetch( to => '/data/documents/'); my $error= $ff->error(); rename ("C:/data/documents/document.pdf","C:/data/documents/documen +t$i.pdf"); ($i++); }
    the other website I tried it on gave me a nasty gram of "Unable to Respond to this Request" "contact the helpdesk" But this will work for now.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-29 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found