Home
Softono
storage-csharp

storage-csharp

Open source MIT C#
26
Stars
13
Forks
4
Issues
6
Watchers
7 months
Last Commit

About storage-csharp

Supabase.Storage is a C implementation of Supabase's Object Storage API, enabling seamless integration of Supabase storage capabilities into .NET applications. This library allows developers to manage file storage operations such as creating public or private buckets, uploading and downloading files, and generating access URLs. For public buckets, it retrieves direct public URLs, while private buckets require generating time-limited signed URLs for secure access. The package is now officially named Supabase.Storage on NuGet, succeeding the legacy storage-csharp name with a fully backward-compatible API. It works alongside the broader supabase-csharp client, providing a unified interface to interact with Supabase services including authentication and real-time features. Developers initialize the client using project-specific environment variables for the Supabase URL and key, then access storage functionality through the client instance. The library supports asynchronous operations for non-blocking file handli

Platforms

Web Self-hosted Windows

Languages

C#

Supabase.Storage

Build and Test NuGet


Integrate your Supabase projects with C#.

[Notice]: v2.0.0 renames this package from storage-csharp to Supabase.Storage. The depreciation notice has been set in NuGet. The API remains the same.

Examples (using supabase-csharp)

public async void Main()
{
  // Make sure you set these (or similar)
  var url = Environment.GetEnvironmentVariable("SUPABASE_URL");
  var key = Environment.GetEnvironmentVariable("SUPABASE_KEY");

  await Supabase.Client.InitializeAsync(url, key);

  // The Supabase Instance can be accessed at any time using:
  //  Supabase.Client.Instance {.Realtime|.Auth|etc.}
  // For ease of readability we'll use this:
  var instance = Supabase.Client.Instance;

  // Interact with Supabase Storage
  var storage = Supabase.Client.Instance.Storage
  await storage.CreateBucket("testing")

  var bucket = storage.From("testing");

  var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace("file:", "");
  var imagePath = Path.Combine(basePath, "Assets", "supabase-csharp.png");

  await bucket.Upload(imagePath, "supabase-csharp.png");

  // If bucket is public, get url
  bucket.GetPublicUrl("supabase-csharp.png");

  // If bucket is private, generate url
  await bucket.CreateSignedUrl("supabase-csharp.png", 3600));

  // Download it!
  await bucket.Download("supabase-csharp.png", Path.Combine(basePath, "testing-download.png"));
}

Package made possible through the efforts of:

Join the ranks! See a problem? Help fix it!

Made with contrib.rocks.

Contributing

We are more than happy to have contributions! Please submit a PR.