Giter VIP home page Giter VIP logo

wetransfer.net's Introduction

WeTransfer.NET Build Status Nuget Package

A .NET Standard library that is a very basic wrapper over the WeTransfer API. This library only implements the Transfer API, there are no plans yet for implementing the Boards API.

Usage

The easiest way to get started is to download the nuget package from here: https://www.nuget.org/packages/WeTransfer.NET/

It's very simple to start uploading files. First you need to get your WeTransfer API from here. Here is a small sample program that will upload an image:

WeTransferClient wt = new WeTransferClient ("your api key here");

// Authorize your WeTransfer app, this call the /authorize endpoint
await wt.Authorize ();

// Create Partial File Information so WeTransfer knows how many files
// you're going to upload, the names of those files and their sizes
PartialFileInfo [] partialFileInfos = new PartialFileInfo [1];
partialFileInfos [0] = new PartialFileInfo
{
    Name = "TestFile.png",
    Path = "/path/to/the/file/TestFile.png",
    // Size of the file in bytes
    Size = 48570239
};

// Create a File Transfer which informs WeTransfer that you're about to upload files
// The second parameter is the transfer message which will show on the download page
FileTransferResponse response = await wt.CreateTransfer (partialFileInfos,
                                                         "Test Transfer");

// Now you can upload the files!
// The first parameter is the transfer's ID
await wt.Upload (response.ID, response.Files);

// Now you need to tell WeTransfer that your files have been uploaded
FileUploadResult result = await wt.FinalizeUpload (response.ID, response.Files);

// FileUploadResult contains the url to the download page and the date of the expiry

Note: Sending multiple files doesn't work as of 1.0. If you need this feature please keep and eye here: #2

Building

If you want to build this from source all you need is .Net SDK and run the dotnet build command.

Unit Tests

This project also includes unit tests (just one for now).

First you have to have the WE_TRANSFER_KEY environment variable set with your API key.

All you need to run the tests is run dotnet test which will upload the TestFile.png image (around 16MB, it's that big to make sure that multipart uploading works as it should).

wetransfer.net's People

Contributors

codemyst avatar

Watchers

 avatar  avatar  avatar

wetransfer.net's Issues

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.