Skip to content

Commit

Permalink
Fix website save export (#929)
Browse files Browse the repository at this point in the history
- Return wrapped response with data property
- Change Content-Type; I've observed my iPhone to default saving the
file as savedata.txt.json and wonder if changing the Content-Type could
fix that to save it as just .txt
  • Loading branch information
SapiensAnatis authored Jul 6, 2024
1 parent 2ae2105 commit ee89214
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using DragaliaAPI.Models;
using DragaliaAPI.Models.Generated;
using DragaliaAPI.Services;
using DragaliaAPI.Shared.Serialization;
Expand All @@ -13,11 +14,15 @@ public class SavefileController(ILoadService loadService) : ControllerBase
[Authorize(Policy = AuthConstants.PolicyNames.RequireDawnshardIdentity)]
public async Task<FileResult> GetSavefile(CancellationToken cancellationToken)
{
LoadIndexResponse savefile = await loadService.BuildIndexData(cancellationToken);
DragaliaResponse<LoadIndexResponse> savefile =
new(
new DataHeaders(ResultCode.Success),
await loadService.BuildIndexData(cancellationToken)
);

return this.File(
JsonSerializer.SerializeToUtf8Bytes(savefile, ApiJsonOptions.Instance),
"application/json",
"text/plain",
"savedata.txt"
);
}
Expand Down

0 comments on commit ee89214

Please sign in to comment.