nearby-sharing / android

Share files between android and PC via the Windows 10 / 11 built-in sharing functionality (Project Rome)
https://nearshare.shortdev.de
GNU General Public License v3.0
646 stars 33 forks source link

Use `FileDescriptor` from `MediaStore` for random file access #130

Closed ShortDevelopment closed 4 months ago

ShortDevelopment commented 4 months ago

Issue

As file-transfer packages might be received out of order, a seekable stream (random file access) is needed. But: Android APIs don't provide random file access with MediaStore. Manually creating a file in the downloads folder might result in an UnauthorizedAccessException.

Solution

Insert entry intro MediaStore (visible in files app) and use the FileDescriptor from OpenFileDescriptor to create a seekabe FileStream (dotnet).


Fixes #125
Fixes #124