benxu.AppPlatform.Supabase.Storage
3.2.8
dotnet add package benxu.AppPlatform.Supabase.Storage --version 3.2.8
NuGet\Install-Package benxu.AppPlatform.Supabase.Storage -Version 3.2.8
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="benxu.AppPlatform.Supabase.Storage" Version="3.2.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="benxu.AppPlatform.Supabase.Storage" Version="3.2.8" />
<PackageReference Include="benxu.AppPlatform.Supabase.Storage" />
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 benxu.AppPlatform.Supabase.Storage --version 3.2.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: benxu.AppPlatform.Supabase.Storage, 3.2.8"
#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 benxu.AppPlatform.Supabase.Storage@3.2.8
#: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=benxu.AppPlatform.Supabase.Storage&version=3.2.8
#tool nuget:?package=benxu.AppPlatform.Supabase.Storage&version=3.2.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
benxu.AppPlatform.Supabase.Storage
Supabase Storage 實作套件,提供物件檔案的上傳、更新、下載、列舉、刪除、搬移、複製,以及公開網址與簽名網址產生能力,適合在 .NET MAUI App 中存取 Supabase Storage。
功能特色
- 使用
Supabase.Storage實作常用的物件儲存操作。 - 提供
Upload / Update / Download / List / Delete / Move / Copy服務介面。 - 支援
GetPublicUrl、CreateSignedUrl與CreateSignedUrls。 - 若系統中已有
IAuthService,可自動帶入使用者 JWT,配合 Supabase Storage 權限規則。 - 保持套件內聚,不將遠端儲存抽象提升到既有平台
Core層。
安裝
dotnet add package benxu.AppPlatform.Supabase.Storage
使用方式
1. 直接註冊服務
using benxu.AppPlatform.Supabase.Storage.Extensions;
builder.Services.AddSupabaseStorage(options =>
{
options.ProjectUrl = "https://your-project.supabase.co";
options.AnonKey = "YOUR_SUPABASE_ANON_KEY";
options.UseAuthTokenWhenAvailable = true;
});
2. 透過 Bootstrap 註冊
using benxu.AppPlatform.MAUI.Bootstrap.Extensions;
builder.UseAppPlatform(options =>
{
options.UseSupabaseStorage(storage =>
{
storage.ProjectUrl = "https://your-project.supabase.co";
storage.AnonKey = "YOUR_SUPABASE_ANON_KEY";
storage.UseAuthTokenWhenAvailable = true;
});
});
3. 上傳與下載檔案
using benxu.AppPlatform.Supabase.Storage.Abstractions;
public class AvatarStorageService
{
private readonly ISupabaseStorageService _storageService;
/// <summary>
/// 建立 AvatarStorageService。
/// </summary>
/// <param name="storageService">Supabase Storage 服務。</param>
public AvatarStorageService(ISupabaseStorageService storageService)
{
_storageService = storageService;
}
/// <summary>
/// 上傳使用者頭像並回傳可用網址。
/// </summary>
/// <param name="userId">使用者識別碼。</param>
/// <param name="localFilePath">本機檔案路徑。</param>
/// <returns>頭像公開網址;若失敗則回傳 <see langword="null"/>。</returns>
public async Task<string?> UploadAvatarAsync(string userId, string localFilePath)
{
var objectPath = $"avatars/{userId}.jpg";
var uploadResult = await _storageService.UploadAsync(
"user-assets",
localFilePath,
objectPath);
if (uploadResult.IsFailure)
{
return null;
}
var publicUrlResult = await _storageService.GetPublicUrlAsync(
"user-assets",
objectPath);
return publicUrlResult.IsSuccess ? publicUrlResult.Data : null;
}
}
注意事項
bucketName與objectPath不可為空。- 本機檔案上傳前會驗證檔案是否存在。
- 若
RequireAuthenticatedSession = true,但目前沒有可用的 Access Token,服務會直接回傳失敗結果。 GetPublicUrlAsync()僅負責產生 URL,不會檢查 bucket 是否真的是 public。
依賴項目
Supabase.Storage(2.4.1)benxu.AppPlatform.CoreMicrosoft.Maui.Controls
授權
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-android36.0
- benxu.AppPlatform.Core (>= 3.2.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Supabase.Storage (>= 2.4.1)
- Xamarin.AndroidX.Activity (>= 1.10.1.3)
- Xamarin.AndroidX.Activity.Ktx (>= 1.10.1.3)
- Xamarin.AndroidX.Collection (>= 1.5.0.3)
- Xamarin.AndroidX.Collection.Jvm (>= 1.5.0.3)
- Xamarin.AndroidX.Collection.Ktx (>= 1.5.0.3)
- Xamarin.Build.Download (>= 0.11.4)
-
net10.0-ios26.0
- benxu.AppPlatform.Core (>= 3.2.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Supabase.Storage (>= 2.4.1)
- Xamarin.Build.Download (>= 0.11.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on benxu.AppPlatform.Supabase.Storage:
| Package | Downloads |
|---|---|
|
benxu.AppPlatform.MAUI.Bootstrap
Bootstrap package for benxu App Platform. Provides fluent API for one-line service registration and lifecycle management. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.8 | 53 | 7/7/2026 |