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
CreateSignedUrl(string, int, TransformOptions?)
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)
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
TransformOptions
Returns
CreateSignedUrls(List<string>, int)
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)
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.
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?)
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)
Parameters
path
stringtransformOptions
TransformOptions
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)
Moves an existing file, optionally renaming it at the same time.
public Task<bool> Move(string fromPath, string toPath)
Parameters
fromPath
stringThe original file path, including the current file name. For example
folder/image.png
.toPath
stringThe new file path, including the new file name. For example
folder/image-copy.png
.
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)
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)
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
bool
Returns
Upload(string, string, FileOptions?, EventHandler<float>?, bool)
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)
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
bool
Returns
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