Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support MultipartRequest in functions invoke #977

Merged
merged 4 commits into from
Jul 24, 2024

Conversation

Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Jul 20, 2024

What kind of change does this PR introduce?

feature

What is the current behavior?

The body can only be of type Map<String,dynamic> and no files can be uploaded.

What is the new behavior?

The body can be any Object, which is encodable to String. There's now a files parameter to send files with a MultipartRequest.

Additional context

At the moment everything is bundled in one method like in functions-js. One could argue to create an extra method to be more type safe with body being Map<String,String>.

close #933

@Vinzent03 Vinzent03 changed the title feat: support MultipartRequest in functions invoke feat: Support MultipartRequest in functions invoke Jul 20, 2024
@Vinzent03 Vinzent03 requested a review from dshukertjr July 21, 2024 11:37
Copy link
Member

@dshukertjr dshukertjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! We probably need to export MultipartFile so that it's available to the users, right?

@Vinzent03
Copy link
Collaborator Author

It's from the http package, which I guess most people have already installed and can import themself. But exporting just that class won't hurt, so I will add that tomorrow.

@dshukertjr
Copy link
Member

It's from the http package, which I guess most people have already installed and can import themself. But exporting just that class won't hurt, so I will add that tomorrow.

Awesome 👍 Just sharing my two cents, but I think it's common for people to not have the HTTP package installed if they are using Supabase.

@Vinzent03 Vinzent03 requested review from dshukertjr and bdlukaa July 23, 2024 20:33
@Vinzent03
Copy link
Collaborator Author

Since more types for the body are allowed now, I've added a basic content header detection. For string inputs, it sets the header to text/plain and for Uint8List as an example for binary data to octet stream.

Copy link
Member

@dshukertjr dshukertjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the automatic content type detection!

@dshukertjr dshukertjr merged commit 09698ed into main Jul 24, 2024
9 checks passed
@dshukertjr dshukertjr deleted the feat/multipartrequest branch July 24, 2024 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does Supabase Flutter functions.invoke support FormData input?
3 participants