Skip to content

Commit

Permalink
perf(FileSavePicker): Add SaveAs binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed May 22, 2023
1 parent 60ab27a commit ed5ef1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
13 changes: 0 additions & 13 deletions src/Uno.UWP/Storage/CachedFileManager.Interop.wasm.cs

This file was deleted.

6 changes: 5 additions & 1 deletion src/Uno.UWP/Storage/CachedFileManager.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Windows.Storage.Provider;

#if NET7_0_OR_GREATER
using NativeMethods = __Windows.Storage.CachedFileManager.NativeMethods;
using NativeMethods = __Windows.Storage.Pickers.FileSavePicker.NativeMethods;
#endif

namespace Windows.Storage
Expand All @@ -31,7 +31,11 @@ private static async Task<FileUpdateStatus> CompleteUpdatesTaskAsync(IStorageFil

try
{
#if NET7_0_OR_GREATER
NativeMethods.SaveAs(file.Name, pinnedData, data.Length);
#else
WebAssemblyRuntime.InvokeJS($"Windows.Storage.Pickers.FileSavePicker.SaveAs('{file.Name}', {pinnedData}, {data.Length})");
#endif
}
finally
{
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UWP/Storage/Pickers/FileSavePicker.Interop.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ internal static partial class NativeMethods

[JSImport($"{JsType}.nativePickSaveFileAsync")]
internal static partial Task<string> PickSaveFileAsync(bool showAll, string fileTypeMap, string suggestedFileName, string id, string startIn);

[JSImport($"{JsType}.SaveAs")]
internal static partial void SaveAs(string fileName, nint pData, int length);
}
}
}
Expand Down

0 comments on commit ed5ef1b

Please sign in to comment.