Class StorageFileApi
public class StorageFileApi : IStorageFileApi<FileObject>
- Inheritance
-
StorageFileApi
- Implements
- Inherited Members
Constructors
StorageFileApi(string, Dictionary<string, string>?, string?)
public StorageFileApi(string url, Dictionary<string, string>? headers = null, string? bucketId = null)
Parameters
url
stringheaders
Dictionary<string, string>bucketId
string
StorageFileApi(string, string, ClientOptions?, Dictionary<string, string>?)
public StorageFileApi(string url, string bucketId, ClientOptions? options, Dictionary<string, string>? headers = null)
Parameters
url
stringbucketId
stringoptions
ClientOptionsheaders
Dictionary<string, string>
Properties
BucketId
protected string? BucketId { get; set; }
Property Value
Headers
protected Dictionary<string, string> Headers { get; set; }
Property Value
Options
public ClientOptions Options { get; protected set; }
Property Value
Url
protected string Url { get; set; }
Property Value
Methods
Copy(string, string, DestinationOptions?)
Copies a file/object from one path to another within a bucket or across buckets.
public Task<bool> Copy(string fromPath, string toPath, DestinationOptions? options = null)
Parameters
fromPath
stringThe source path of the file/object to copy.
toPath
stringThe destination path for the copied file/object.
options
DestinationOptionsOptional parameters such as the destination bucket.
Returns
CreateSignedUrl(string, int, TransformOptions?, DownloadOptions?)
Create signed url to download file without requiring permissions. This URL can be valid for a set number of seconds.
public Task<string> CreateSignedUrl(string path, int expiresIn, TransformOptions? transformOptions = null, DownloadOptions? downloadOptions = null)
Parameters
path
stringThe file path to be downloaded, including the current file name. For example
folder/image.png
.expiresIn
intThe number of seconds until the signed URL expires. For example,
60
for a URL which is valid for one minute.transformOptions
TransformOptionsdownloadOptions
DownloadOptions
Returns
CreateSignedUrls(List<string>, int, DownloadOptions?)
Create signed URLs to download files without requiring permissions. These URLs can be valid for a set number of seconds.
public Task<List<CreateSignedUrlsResponse>?> CreateSignedUrls(List<string> paths, int expiresIn, DownloadOptions? downloadOptions = null)
Parameters
paths
List<string>paths The file paths to be downloaded, including the current file names. For example [
folder/image.png
, 'folder2/image2.png'].expiresIn
intThe number of seconds until the signed URLs expire. For example,
60
for URLs which are valid for one minute.downloadOptions
DownloadOptions
Returns
CreateUploadSignedUrl(string)
Creates an upload signed URL. Use it to upload a file straight to the bucket without credentials
public Task<UploadSignedUrl> CreateUploadSignedUrl(string supabasePath)
Parameters
supabasePath
stringThe file path, including the current file name. For example
folder/image.png
.
Returns
Download(string, TransformOptions?, EventHandler<float>?)
Downloads a byte array from a private bucket to be used programmatically. For public buckets DownloadPublicFile(string, TransformOptions?, EventHandler<float>?)
public Task<byte[]> Download(string supabasePath, TransformOptions? transformOptions = null, EventHandler<float>? onProgress = null)
Parameters
supabasePath
stringtransformOptions
TransformOptionsonProgress
EventHandler<float>
Returns
Download(string, EventHandler<float>?)
Downloads a byte array from a private bucket to be used programmatically. For public buckets DownloadPublicFile(string, TransformOptions?, EventHandler<float>?)
public Task<byte[]> Download(string supabasePath, EventHandler<float>? onProgress = null)
Parameters
supabasePath
stringonProgress
EventHandler<float>
Returns
Download(string, string, TransformOptions?, EventHandler<float>?)
Downloads a file from a private bucket. For public buckets, use DownloadPublicFile(string, string, TransformOptions?, EventHandler<float>?)
public Task<string> Download(string supabasePath, string localPath, TransformOptions? transformOptions = null, EventHandler<float>? onProgress = null)
Parameters
supabasePath
stringlocalPath
stringtransformOptions
TransformOptionsonProgress
EventHandler<float>
Returns
Download(string, string, EventHandler<float>?)
Downloads a file from a private bucket. For public buckets, use DownloadPublicFile(string, string, TransformOptions?, EventHandler<float>?)
public Task<string> Download(string supabasePath, string localPath, EventHandler<float>? onProgress = null)
Parameters
supabasePath
stringlocalPath
stringonProgress
EventHandler<float>
Returns
DownloadPublicFile(string, TransformOptions?, EventHandler<float>?)
Downloads a byte array from a private bucket to be used programmatically. This method DOES NOT VERIFY that the file is actually public.
public Task<byte[]> DownloadPublicFile(string supabasePath, TransformOptions? transformOptions = null, EventHandler<float>? onProgress = null)
Parameters
supabasePath
stringtransformOptions
TransformOptionsonProgress
EventHandler<float>
Returns
DownloadPublicFile(string, string, TransformOptions?, EventHandler<float>?)
Downloads a public file to the filesystem. This method DOES NOT VERIFY that the file is actually public.
public Task<string> DownloadPublicFile(string supabasePath, string localPath, TransformOptions? transformOptions = null, EventHandler<float>? onProgress = null)
Parameters
supabasePath
stringlocalPath
stringtransformOptions
TransformOptionsonProgress
EventHandler<float>
Returns
GetPublicUrl(string, TransformOptions?, DownloadOptions?)
A simple convenience function to get the URL for an asset in a public bucket.If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset. This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
public string GetPublicUrl(string path, TransformOptions? transformOptions, DownloadOptions? downloadOptions = null)
Parameters
path
stringtransformOptions
TransformOptionsdownloadOptions
DownloadOptions
Returns
Info(string)
Retrieves the details of an existing file.
public Task<FileObjectV2?> Info(string path)
Parameters
path
string
Returns
List(string, SearchOptions?)
Lists all the files within a bucket.
public Task<List<FileObject>?> List(string path = "", SearchOptions? options = null)
Parameters
path
stringoptions
SearchOptions
Returns
Move(string, string, DestinationOptions?)
Moves an existing file to a new location, optionally allowing renaming.
public Task<bool> Move(string fromPath, string toPath, DestinationOptions? options = null)
Parameters
fromPath
stringThe original file path, including the current file name (e.g.,
folder/image.png
).toPath
stringThe target file path, including the new file name (e.g.,
folder/image-copy.png
).options
DestinationOptionsOptional parameters for specifying the destination bucket and other settings.
Returns
Remove(List<string>)
Deletes files within the same bucket
public Task<List<FileObject>?> Remove(List<string> paths)
Parameters
paths
List<string>An array of files to be deletes, including the path and file name. For example [
folder/image.png
].
Returns
Remove(string)
Deletes file within the same bucket
public Task<FileObject?> Remove(string path)
Parameters
path
stringA path to delete, for example
folder/image.png
.
Returns
Update(byte[], string, FileOptions?, EventHandler<float>?)
Replaces an existing file at the specified path with a new one.
public Task<string> Update(byte[] data, string supabasePath, FileOptions? options = null, EventHandler<float>? onProgress = null)
Parameters
data
byte[]supabasePath
stringThe relative file path. Should be of the format
folder/subfolder/filename.png
. The bucket must already exist before attempting to upload.options
FileOptionsHTTP headers.
onProgress
EventHandler<float>
Returns
Update(string, string, FileOptions?, EventHandler<float>?)
Replaces an existing file at the specified path with a new one.
public Task<string> Update(string localFilePath, string supabasePath, FileOptions? options = null, EventHandler<float>? onProgress = null)
Parameters
localFilePath
stringFile source path.
supabasePath
stringThe relative file path. Should be of the format
folder/subfolder/filename.png
. The bucket must already exist before attempting to upload.options
FileOptionsHTTP headers.
onProgress
EventHandler<float>
Returns
Upload(byte[], string, FileOptions?, EventHandler<float>?, bool, CancellationToken)
Uploads a byte array to an existing bucket.
public Task<string> Upload(byte[] data, string supabasePath, FileOptions? options = null, EventHandler<float>? onProgress = null, bool inferContentType = true, CancellationToken cancellationToken = default)
Parameters
data
byte[]supabasePath
stringThe relative file path. Should be of the format
folder/subfolder/filename.png
. The bucket must already exist before attempting to upload.options
FileOptionsonProgress
EventHandler<float>inferContentType
boolcancellationToken
CancellationToken
Returns
Upload(string, string, FileOptions?, EventHandler<float>?, bool, CancellationToken)
Uploads a file to an existing bucket.
public Task<string> Upload(string localFilePath, string supabasePath, FileOptions? options = null, EventHandler<float>? onProgress = null, bool inferContentType = true, CancellationToken cancellationToken = default)
Parameters
localFilePath
stringFile Source Path
supabasePath
stringThe relative file path. Should be of the format
folder/subfolder/filename.png
. The bucket must already exist before attempting to upload.options
FileOptionsonProgress
EventHandler<float>inferContentType
boolcancellationToken
CancellationToken
Returns
UploadOrResume(byte[], string, FileOptions?, EventHandler<float>?, CancellationToken)
Uploads a file to the specified path in Supabase storage or resumes an interrupted upload process. Allows customization through provided file options and supports tracking upload progress via an event handler.
public Task UploadOrResume(byte[] data, string fileName, FileOptions? options, EventHandler<float>? onProgress = null, CancellationToken cancellationToken = default)
Parameters
data
byte[]The byte array containing the file data to upload.
fileName
stringThe destination path within Supabase storage where the file should be stored.
options
FileOptionsOptional configuration settings for the upload process.
onProgress
EventHandler<float>An optional event handler for monitoring the upload progress, reporting it as a percentage.
cancellationToken
CancellationTokenA cancellation token to observe while awaiting the task, allowing the operation to be canceled.
Returns
- Task
A task representing the asynchronous operation, resolving to the path of the uploaded file upon successful completion.
UploadOrResume(string, string, FileOptions?, EventHandler<float>?, CancellationToken)
Attempts to upload a file to Supabase storage. If the upload process is interrupted or incomplete, it will attempt to resume the upload.
public Task UploadOrResume(string localPath, string fileName, FileOptions? options, EventHandler<float>? onProgress = null, CancellationToken cancellationToken = default)
Parameters
localPath
stringThe local file path of the file to be uploaded.
fileName
stringThe destination path in Supabase Storage where the file will be stored.
options
FileOptionsOptional file options to specify metadata or other upload configurations.
onProgress
EventHandler<float>An optional event handler for tracking and reporting upload progress as a percentage.
cancellationToken
CancellationTokenCancellation token to observe while waiting for the task to complete.
Returns
- Task
Returns a task that resolves to a string representing the URL or path of the uploaded file in the storage.
UploadToSignedUrl(byte[], UploadSignedUrl, FileOptions?, EventHandler<float>?, bool)
Uploads a byte array using a pre-generated Signed Upload Url
public Task<string> UploadToSignedUrl(byte[] data, UploadSignedUrl signedUrl, FileOptions? options = null, EventHandler<float>? onProgress = null, bool inferContentType = true)
Parameters
data
byte[]signedUrl
UploadSignedUrloptions
FileOptionsonProgress
EventHandler<float>inferContentType
bool
Returns
UploadToSignedUrl(string, UploadSignedUrl, FileOptions?, EventHandler<float>?, bool)
Uploads a file to using a pre-generated Signed Upload Url
public Task<string> UploadToSignedUrl(string localFilePath, UploadSignedUrl signedUrl, FileOptions? options = null, EventHandler<float>? onProgress = null, bool inferContentType = true)
Parameters
localFilePath
stringFile Source Path
signedUrl
UploadSignedUrloptions
FileOptionsonProgress
EventHandler<float>inferContentType
bool