supabase-community / storage-csharp

A C# implementation of Supabase's Object Storage API
https://supabase-community.github.io/storage-csharp/api/Supabase.Storage.Client.html
MIT License
19 stars 7 forks source link

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

Open ninoalloy opened 3 months ago

ninoalloy commented 3 months ago

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; }
    }
  2. 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.