-
Notifications
You must be signed in to change notification settings - Fork 14
📶Refit guidelines
Strypper Vandel Jason edited this page Feb 26, 2023
·
1 revision
- Create a
StreamPart
type first: _file isFilePicker
service this is already built inside the project
StreamPart:
`_file = await filePicker.OpenMediaPickerAsync();`
`using var imageStream = File.OpenRead(_file.FullPath);`
`var imageFromStream = new StreamPart(imageStream, _file.FileName);`
ByteArrayPart:
`_file = await filePicker.OpenMediaPickerAsync();`
`var imageByteArray = await File.ReadAllBytesAsync(_file.FullPath);`
`var imageFromByteArray = new ByteArrayPart(imageByteArray, _file.FileName);`
- Put AliasAs to help Refit define the request body name better
[Multipart] [Put("/User/UploadAvatar")] Task UploadAvatar([Authorize("Bearer")] string token, [AliasAs("avatar")] StreamPart avatar);