storage-csharp icon indicating copy to clipboard operation
storage-csharp copied to clipboard

[Storage] Add support for 'download' parameter to CreateSignedUrl, CreateSignedUrls and GetPublicUrl

Open ninoalloy opened this issue 1 year ago • 0 comments

Feature request

Looking at the docs for the JS Sdk (https://supabase.com/docs/reference/javascript/storage-from-createsignedurl) under options, it is possible to provide a download request parameter to control whether the resulting URL(s) triggers or not a download in the browser.

This option does not seem to be currently supported by the C# Sdk.

Describe the solution you'd like

The download parameter should be added to the accepted parameters of all 3 methods mentioned above.

image However download in the JS Sdk can either be a bool or a string to give the possibility to override the downloaded file name.

The implementation choices I can think of are:

  1. Add a DownloadOptions class: If Download is set to false (FileNameOverride is ignored), then a link without download headers is generated. If Download is set to true and FileNameOverride is provided, then a link with download headers and overridden file name is generated. If Download is set to true and FileNameOverride is null or empty, then a link with download headers and default file name is generated.
public class DownloadOptions
{
    public bool Download { get; }
    public string? FileNameOverride { get; }
}
  1. Add a method override for each of the 3 methods above with a bool download parameter and a string? fileNameOverride one. Same rules as choice 1 apply.

Describe alternatives you've considered

I cannot think of any alternative other than contacting the Supabase Api directly.

Additional context

I would be happy to implement the feature and open a PR once we have reached consensus on a design.

ninoalloy avatar Jul 30 '24 13:07 ninoalloy