Giter Club home page Giter Club logo

cake.curl's Introduction

Cake.Curl

Package Windows Linux Tests
NuGet AppVeyor Travis CI Tests

Cake.Curl is a cross-platform add-in for Cake that allows to transfer files to and from remote URLs using curl.

Cross-platform

Cake.Curl targets the .NET Standard 2.0 and the .NET Framework 4.6. As such, it will run on Linux, macOS and Windows.

Prerequisites

In order to use Cake.Curl, you will need to have a copy of the curl executable for your OS. It doesn't have to be in a specific location; as long as it's included in your PATH environment variable, Cake will find it.

Usage

The purpose of this add-in is to expose the functionality of curl to the Cake DSL by being a very thin wrapper around its command line interface; this means that you can use Cake.Curl in the same way as you would normally use curl, only with a different interface.

Here are a few examples of how some common usage scenarios would look like in a Cake script.

First of all, you need to import Cake.Curl in your build script by using the add-in directive:

#addin Cake.Curl

Downloading Files

Downloading a text file from a remote HTTP server onto the working directory:

Task("Download")
    .Does(() =>
{
    CurlDownloadFile(new Uri("http://host/file.txt"));
});

Downloading a sequence of text files numbered between 1 and 10 from a remote HTTP server onto the working directory:

Task("Download")
    .Does(() =>
{
    CurlDownloadFile(new Uri("http://host/file[1-10].txt"));
});

Downloading a text file from a remote HTTP server onto the working directory and giving it a different name:

Task("Download")
    .Does(() =>
{
    CurlDownloadFile(
        new Uri("http://host/file.txt"),
        new CurlDownloadSettings
        {
            OutputPaths = new FilePath[] { "renamed.txt" }
        });
});

Downloading multiple files concurrently from different servers onto the working directory:

Task("Download")
    .Does(() =>
{
    CurlDownloadFiles(new[]
    {
        new Uri("ftp://host/file.txt"),
        new Uri("ftp://anotherhost/anotherfile.txt"),
        new Uri("http://yetanotherhost/yetanotherfile.txt")
    }
});

Downloading multiple files into specific paths:

Task("Download")
    .Does(() =>
{
    CurlDownloadFiles(
        new[]
        {
            new Uri("ftp://host/file.txt"),
            new Uri("http://anotherhost/anotherfile.txt"),
        }
        new CurlDownloadSettings
        {
            OutputPaths = new FilePath[]
            {
                "some/path/file.txt",
                "some/other/path/anotherfile.txt"
            }
        });
});

Uploading Files

Uploading a local text file to a remote HTTP server:

Task("Upload")
    .Does(() =>
{
    CurlUploadFile("some/file.txt", new Uri("http://host/path"));
});

Uploading a local text file to a remote FTPS server using credentials:

Task("Upload")
    .Does(() =>
{
    CurlUploadFile(
        "some/file.txt",
        new Uri("ftps://host/path"),
        new CurlSettings
        {
            Username = "username",
            Password = "password"
        });
});

Custom HTTP Headers

Transferring a file using a custom HTTP header in the request:

Task("Upload")
    .Does(() =>
{
    CurlUploadFile(
        "some/file.txt",
        new Uri("http://host/path"),
        new CurlSettings
        {
            Headers = new Dictionary<string, string>
            {
                ["X-SomeHeader"] = "SomeValue"
            }
        });
});

Additional Resources

You can find more information about how to use Cake.Curl in the official documentation for these projects:

You can also see Cake.Curl in action in the following videos:

cake.curl's People

Contributors

deqenq avatar ecampidoglio avatar johanbenschop avatar jzeferino avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.