GoFileSharp 1.1.1

dotnet add package GoFileSharp --version 1.1.1
                    
NuGet\Install-Package GoFileSharp -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GoFileSharp" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoFileSharp" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="GoFileSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GoFileSharp --version 1.1.1
                    
#r "nuget: GoFileSharp, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GoFileSharp@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GoFileSharp&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=GoFileSharp&version=1.1.1
                    
Install as a Cake Tool

Run Tests Publish Nuget <img alt="NuGet Version" src="https://img.shields.io/nuget/v/GoFileSharp?label=GoFileSharp Nuget">

GoFileSharp

A .NET library for the GoFile.io API written in C#

Available on Nuget

Requirments

  • NewtonSoft.Json

Allowed Methods by Account Type

GoFile Class

Method Guest Standard Premium
UploadFileAsync
GetMyAccountAsync
GetFolderAsync
GetMyRootFolderAsync
  • GoFileFolder and GoFileFile classes can only be accessed by premium accounts because they require you to be able to get content from the API
  • A complete API access breakdown is available on the GoFile API Docs page

Examples

Setting up

You can create a new GoFile instance to access the API, optionally passing in a GoFileOptions object

Options Include:

  • ApiToken: The token to use with all requests, defaults to null
  • PreferredZone: The preferred zone to use when uploading files, defaults to Any

Not providing a premium api token will severly limit api access.

using GoFileSharp;

var goFile = new GoFile(new GoFileOptions
{
    ApiToken = "123-456-7890",
    PreferredZone = ServerZone.NorthAmerica
});

Get your account details

var account = await goFile.GetMyAccountAsync();

Get your root folder

var rootFolder = await goFile.GetMyRootFolderAsync();

Creating a folder

var newFolder = await rootFolder.CreateFolderAsync("My New Folder");

Uploading a file

var fileInfo = new FileInfo(@"c:\path\to\a\file.txt");

// optional progress object for handling progress updates
var uploadProgress = new Progress<double>((percent) => 
{
    Console.WriteLine($"Upload: {fileInfo.Name} @ {percent}%");
});

var uploadedFile = await newFolder.UploadIntoAsync(fileInfo, uploadProgress);

You can add a direct link to files and folders and optionally pass in a DirectLinkOptinosBuilder to set the options on the link.

If you already have a direct link, you can also update it

var optionsBuuilder = new DirectLinkOptionsBuilder()
    .WithExpireTime(DateTime.Now.AddDays(5))
    .AddAllowedDomain("waffle-lord.com")
    .AddAuth("user", "password");

// you can also add the options when creating the initial link here
var directLink = await uploadedFile.AddDirectLinkAsync();

var updatedLink = await uploadedFile.UpdateDirectLinkAsync(directLink, optionsBuuilder);
// returns true if the link was removed, otherwise false
var removed = await uploadedFile.RemoveDirectLinkAsync(updatedLink);

Setting file/folder options

Setting an option will always return a bool value. True is success, otherwise false

// files can only have their name updated
var ok = await uploadedFile.SetNameAsync("my new name.txt");

// folders have quite a few more options
ok = await newFolder.SetNameAsync("some name here");
ok = await newFolder.SetDescriptionAsync("my cool folder description");
ok = await newFolder.SetExpireAsync(DateTime.Now.AddDays(5));
ok = await newFolder.SetPublicAsync(true);
ok = await newFolder.SetPasswordAsync("password");
ok = await newFolder.SetTagsAsync(new[] {"tag1", "tag2", "tag3"}.ToList());

Downloading a file

var destinationFile = new FileInfo(@"c:\path\to\save\file.txt");

// optional progress object for handling progress updates
var downloadProgress = new Progress<double>((percent) =>
{
    Console.WriteLine($"Download: {destinationFile.Name} @ {percent}%");
});

var downloadResult = await uploadedFile.DownloadAsync(destinationFile, false, uploadProgress);

Getting a specific file or folder inside another folder

var someFile = rootFolder.FindFile("somefile.txt");
var someFolder = await rootFolder.FindFolderAsync("Some Folder");

Copying content

// Copy data into a folder object
var myDestFolder = await rootFolder.FindFolderAsync("my destination folder");

var copyResult = await myDestFolder.CopyIntoAsync(new GoFileSharp.Interfaces.IContent[] { someFile, someFolder });

// Or copy content to a destination folder
var fileCopyResult = await someFile.CopyToAsync(myDestFolder);
var folderCopyReult = await someFolder.CopyToAsync(myDestFolder);

Delete a file or folder

var fileDeleteResult = await someFile.DeleteAsync();
var folderDeleteResult = await someFolder.DeleteAsync();
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 232 4/16/2024
1.1.0 162 4/16/2024
1.0.4 185 3/18/2024
1.0.3 188 3/15/2024
1.0.2 176 3/15/2024
1.0.0 180 3/14/2024