Monday, October 23, 2023
HomeiOS DevelopmentOpenReadAsync returns ex Entry to the trail is denied with sharing goal...

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


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

All of the described habits works on simulator, however fails on actual system.

The OpenReadAsync operate is already used and dealing after I choose the file through 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 "/personal/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 habits if I exploit System.IO.File.ReadAllBytes(filePath)

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

However I can not determine the right way 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 at all times returns null.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments