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
urlstringheadersDictionary<string, string>bucketIdstring
StorageFileApi(string, string, ClientOptions?, Dictionary<string, string>?)
public StorageFileApi(string url, string bucketId, ClientOptions? options, Dictionary<string, string>? headers = null)
Parameters
urlstringbucketIdstringoptionsClientOptionsheadersDictionary<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
pathstringThe file path to be downloaded, including the current file name. For example
folder/image.png.expiresInintThe number of seconds until the signed URL expires. For example,
60for a URL which is valid for one minute.transformOptionsTransformOptions
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
pathsList<string>paths The file paths to be downloaded, including the current file names. For example [
folder/image.png, 'folder2/image2.png'].expiresInintThe number of seconds until the signed URLs expire. For example,
60for 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
supabasePathstringThe 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
supabasePathstringtransformOptionsTransformOptionsonProgressEventHandler<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
supabasePathstringonProgressEventHandler<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
supabasePathstringlocalPathstringtransformOptionsTransformOptionsonProgressEventHandler<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
supabasePathstringlocalPathstringonProgressEventHandler<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
supabasePathstringtransformOptionsTransformOptionsonProgressEventHandler<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
supabasePathstringlocalPathstringtransformOptionsTransformOptionsonProgressEventHandler<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
pathstringtransformOptionsTransformOptions
Returns
List(string, SearchOptions?)
Lists all the files within a bucket.
public Task<List<FileObject>?> List(string path = "", SearchOptions? options = null)
Parameters
pathstringoptionsSearchOptions
Returns
Move(string, string)
Moves an existing file, optionally renaming it at the same time.
public Task<bool> Move(string fromPath, string toPath)
Parameters
fromPathstringThe original file path, including the current file name. For example
folder/image.png.toPathstringThe 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
pathsList<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
pathstringA 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
databyte[]supabasePathstringThe relative file path. Should be of the format
folder/subfolder/filename.png. The bucket must already exist before attempting to upload.optionsFileOptionsHTTP headers.
onProgressEventHandler<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
localFilePathstringFile source path.
supabasePathstringThe relative file path. Should be of the format
folder/subfolder/filename.png. The bucket must already exist before attempting to upload.optionsFileOptionsHTTP headers.
onProgressEventHandler<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
databyte[]supabasePathstringThe relative file path. Should be of the format
folder/subfolder/filename.png. The bucket must already exist before attempting to upload.optionsFileOptionsonProgressEventHandler<float>inferContentTypebool
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
localFilePathstringFile Source Path
supabasePathstringThe relative file path. Should be of the format
folder/subfolder/filename.png. The bucket must already exist before attempting to upload.optionsFileOptionsonProgressEventHandler<float>inferContentTypebool
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
databyte[]signedUrlUploadSignedUrloptionsFileOptionsonProgressEventHandler<float>inferContentTypebool
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
localFilePathstringFile Source Path
signedUrlUploadSignedUrloptionsFileOptionsonProgressEventHandler<float>inferContentTypebool