OpenReadAsync returns ex Entry to the trail is denied with sharing goal xamarin ios


I am implementing sharing goal in my Xamarin.iOS undertaking.

All of the described conduct works on simulator, however fails on actual machine.

The OpenReadAsync operate is already used and dealing once I choose the file by way of the FilePicker (file sort is FileResult):

var file = await FilePicker.PickAsync(allowedFileTypes);
utilizing Stream stream = await file.OpenReadAsync();

But when I attempt to create the FileResult manually with the trail I get from the sharing goal:

FileResult file = new FileResult(filePath);
utilizing Stream stream = await file.OpenReadAsync();

I get these 2 exceptions:

{System.IO.DirectoryNotFoundException: Couldn't discover part of the trail "/var/cellular/Media/PhotoData/OutgoingTemp/EF8C049F-C529-44DB-B6FD-3CC6B3ED189D/IMG_0003.JPG".
  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAc…}
{System.UnauthorizedAccessException: Entry to the trail "/non-public/var/cellular/Containers/Shared/AppGroup/0B20B6FA-C27F-4487-9719-D877CAD58452/File Supplier Storage/Downloads/IMG_0003.JPG" is denied.
  at System.IO.FileStream..ctor (System.String path, System.IO.…}

Identical conduct if I take advantage of System.IO.File.ReadAllBytes(filePath)

The manually created file clearly miss some entry proper and the simulator is not that restrictive as an actual machine.

However I can not determine methods to learn bytes from a file from simply the trail given by the sharing extension.

I additionally tried doing the conversion to bytes on the iOS aspect utilizing

NSUrl nSUrl = new NSUrl(cleanUri);
nSUrl.StartAccessingSecurityScopedResource();
var knowledge = NSData.FromUrl(nSUrl);

However NSData.FromUrl all the time returns null.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles