I'm writing a MAUI app that fetches an image from a remote API and would like to save it to the device's storage. The problem I'm facing is with it working on Android API 33.
As the permissions changed, the FileSaver class from the MAUI Community Toolkit still demands the WRITE_EXTERNAL_STORAGE permission, which no longer exists, so it serves DENIED as default. I've seen people mentioning that you can downgrade to a lower API, but with Google's change to their Play store policy, this is not an option.
Has anyone managed or knows how I could get the FileSaver working on API 33 with .NET 7 or is there another way to save files so they could be accessed outside the app?
This is my Android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="si.stroka.signature365" android:versionName="1">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="Signature365 Android"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS_PRIVILEGED" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCOUNT_MANAGER" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Thanks!
Edit: Adding source code for how I request FileSaver. The dialog doesn't appear at all, it just throws the Storage permission not granted message in the exception. I was able to get it to work setting target SDK to 31, but that isn't an option for my app with Google Play Store demanding 33 in August...
using var stream = new MemoryStream(Encoding.Default.GetBytes("Hello from the Community Toolkit!"));
var fileSaverResult = await FileSaver.Default.SaveAsync("test.txt", stream, token.Token);
if (fileSaverResult.IsSuccessful)
{
await Toast.Make($"The file was saved successfully to location: {fileSaverResult.FilePath}").Show(token.Token);
}
else
{
await Toast.Make($"The file was not saved successfully with error: {fileSaverResult.Exception.Message}").Show(token.Token);
}