Replies: 3 comments 1 reply
-
|
@frogcrush Thanks for taking the time to bring this up. I have never tried using Refit to download files directly. I would build something like this on the backend by creating an endpoint with a response payload that includes a short-lived URL and some metadata to the actual file to be downloaded. |
Beta Was this translation helpful? Give feedback.
-
|
Well it is not downloading static files, they are dynamic from the server (server is returning FileStreamResult) - when using just Refit before I could use HttpResponseMessage instead of IApiResponse and access the stream without issue. Is there any way to have Refitter detect if an endpoint is returning I thought that's what responseTypeOverride would do but it doesn't appear to (at least with my configuration). I can see that Refitter is correctly seeing that the endpoints return [Headers("Accept: application/octet-stream")]
[Get("/api/projects/{id}/coverphoto")]
Task<IApiResponse<FileResponse>> GetProjectCoverPhoto(string id); |
Beta Was this translation helpful? Give feedback.
-
@frogcrush the For example: "responseTypeOverride": {
"getPetById": "IApiResponse<Pet>",
"getPetImageById": "System.Net.Http.HttpContent"
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to transfer files from my ASP.NET Core app to my desktop apps that use Refitter to generate API libraries.
Using the following Refitter file:
{ "openApiPath": "blah.json", "namespace": "X.Clients", "naming": { "useOpenApiTitle": false, "interfaceName": "XClient" }, "outputFolder": "GeneratedCode", "outputFilename": "XAPI.cs", "returnIApiResponse": true, "generateContracts": false, "optionalParameters": false, "generateDefaultAdditionalProperties": false, "codeGeneratorSettings": { "dateType": "System.DateOnly", "dateTimeType": "System.DateTimeOffset", "timeType": "System.TimeOnly", "timeSpanType": "System.TimeSpan" } }I had an issue where it kept generating endpoints with IApiResponse but FileResponse did not exist. I turned on GenerateContracts and copied the FileResponse model:
But when I try and get the file at runtime it hits a serialization error. I'm thinking maybe IApiResult is trying to deserialize the file into the FileResponse?
I tried setting responseTypeOverride:
But there was no effect.
What is the correct approach to be downloading files?
Beta Was this translation helpful? Give feedback.
All reactions