Please provide the following:
- SDK Version: 41
- Platforms(Android/iOS/web/all): Android
- Add the appropriate “Tag” based on what Expo library you have a question on.
The following code creates a file test.txt under Internal Storage/Pictures/TestFolder/
Is it possible to make it save to the downloads folder? How should this be done properly in Android 11 given the new restrictions?
import * as MediaLibrary from 'expo-media-library';
import * as FileSystem from 'expo-file-system';
...
var data = "Test Data String"
const res = await MediaLibrary.requestPermissionsAsync();
if (res.granted) {
var fileUri = FileSystem.documentDirectory + "test.txt";
await FileSystem.writeAsStringAsync(fileUri, data, { encoding: FileSystem.EncodingType.UTF8 });
const asset = await MediaLibrary.createAssetAsync(fileUri)
await MediaLibrary.createAlbumAsync("TestFolder", asset, false)
} else {
console.log("permission not granted")
}