FetchFile

NAME

URI::FetchFile - retrieve a file from the internet by any means necessary

SYNOPSIS


use URI::FetchFile;

if fetch-uri('http://rakudo.org/downloads/star/rakudo-star-2016.10.tar.gz', 'rakudo-star-2016.10.tar.gz') {
    # do something with the file
}
else {
    die "couldn't get file";
}

DESCRIPTION

This provides a simple method of retrieving a single file via HTTP using the best available method whilst trying to limit the dependencies.

It is intended to be used by installers or builders that may need to retrieve a file but otherwise have no need for an HTTP client.

It will try to use the first available method from:

  • HTTP::UserAgent

  • LWP::Simple

  • curl

  • wget

Failing with a X::NoProvider if it can't use any of them.

ROUTINES

sub fetch-uri

sub fetch-uri(Str $uri, Str $file ) returns Bool is export(:DEFAULT)

This will attempt to get the resource identified by URI and save the returned resource in the specified $file. If the resource cannot be retrieved then this will return False (and the file won't be created.) If none of the providers are available an exception will be thrown.

URI::FetchFile v0.0.5

retrieve a file from the internet by the best available method

Authors

  • Jonathan Stowe

License

Artistic-2.0

Dependencies

File::Which

Test Dependencies

Provides

  • URI::FetchFile

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.