GoFileSharp 1.1.1
dotnet add package GoFileSharp --version 1.1.1
NuGet\Install-Package GoFileSharp -Version 1.1.1
<PackageReference Include="GoFileSharp" Version="1.1.1" />
<PackageVersion Include="GoFileSharp" Version="1.1.1" />
<PackageReference Include="GoFileSharp" />
paket add GoFileSharp --version 1.1.1
#r "nuget: GoFileSharp, 1.1.1"
#:package GoFileSharp@1.1.1
#addin nuget:?package=GoFileSharp&version=1.1.1
#tool nuget:?package=GoFileSharp&version=1.1.1
<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#
Requirments
- NewtonSoft.Json
Allowed Methods by Account Type
GoFile Class
| Method | Guest | Standard | Premium |
|---|---|---|---|
| UploadFileAsync | ✅ | ✅ | ✅ |
| GetMyAccountAsync | ❌ | ✅ | ✅ |
| GetFolderAsync | ❌ | ❌ | ✅ |
| GetMyRootFolderAsync | ❌ | ❌ | ✅ |
GoFileFolderandGoFileFileclasses 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 tonullPreferredZone: The preferred zone to use when uploading files, defaults toAny
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);
Adding/Updating a direct link
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);
Removing a direct link
// 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 | Versions 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. |
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.