GoFileSharp 1.0.0
See the version list below for details.
dotnet add package GoFileSharp --version 1.0.0
NuGet\Install-Package GoFileSharp -Version 1.0.0
<PackageReference Include="GoFileSharp" Version="1.0.0" />
<PackageVersion Include="GoFileSharp" Version="1.0.0" />
<PackageReference Include="GoFileSharp" />
paket add GoFileSharp --version 1.0.0
#r "nuget: GoFileSharp, 1.0.0"
#:package GoFileSharp@1.0.0
#addin nuget:?package=GoFileSharp&version=1.0.0
#tool nuget:?package=GoFileSharp&version=1.0.0
GoFileSharp
A .NET library for the GoFile.io API written in C#
Requirments
- NewtonSoft.Json
Examples
Setting up
You can create a new GoFile instance to access the API, optionally passing in a GoFileOptions object
Options Include:
| Name | Description |
|---------------|-------------------------------------------------------------------|
| 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 an api token will mean limited 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.AddDirectLink();
var updatedLink = await uploadedFile.UpdateDirectLink(directLink, optionsBuuilder);
Removing a direct link
// returns true if the link was removed, otherwise false
var removed = await uploadedFile.RemoveDirectLink(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.SetName("my new name.txt");
// folders have quite a few more options
ok = await newFolder.SetName("some name here");
ok = await newFolder.SetDescription("my cool folder description");
ok = await newFolder.SetExpire(DateTime.Now.AddDays(5));
ok = await newFolder.SetPublic(true);
ok = await newFolder.SetPassword("password");
ok = await newFolder.SetTags(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.