We currently are workiong on an share extension for mediafiles. Every thing working fine expecpt .mov files.
Every kind of attempt to load them in an stream or get any bit of the shared .mov files failed with an app crash.
Could anyone say why or has an solution for this kind of poblem?
We tried:
NSData().AsSteam/.ToArray and foreach
File.Load()
FileInfo.openRead()
AVAssets
Answers
Are you trying to read the stream in the extension?
I suggest storing them directly in the shared container and then analyze them in your container application.
We need to enable the App Group before achieving it:
https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/provisioning/capabilities/app-groups-capabilities
Storring in the shared Container it self is not possible because that this operation cause the same result that the app crashes without exception. Every attemt of an file oparation isn't posible for.mov files in the extension and app.
How did you manipulate the files in your share extension? Could you please share some code here?
We could try to retrieve the URL of the videos like:
Copy the file to the storage through this path or pass it directly to the container app.
To get the NsUrl its the same code as you postet, and from there on if tryed to get the file as stream with NSData.FromURL(movieUrl ).AsStream() or .ToArry(); File.load(movieUrl .Path); FileInfo.OpenRead(movieUrl .Path);
To Copy File.Copy(movieUrl.Path, Path to App Group Share); FileInfo.CopyTo(Path to App Group Share);
and i try to get the byts of NSData from an For/Foreach loop manuely its all the same result.
Try to copy it to the container directly instead of reading the data:
copy work but the file couldn't be load by the extension and app
What do you mean it couldn't be loaded?
Can you retrieve the video from shared container in the container app?
No, loading the video from the shared container results in the same crash of the app and extension, then loading it from the location that's be provided by IOS for the share extension
Do you mean even though you retrieve data in the main app it will still crash?
Could you please post the exception here?
Make sure the file has been stored successfully at the destination path.
And how did you get the data from a specific path?
I dont get any Usefull Exception, Dot.Net shown nothing try catch did not working. And the ios device logs shows only an invalid json (it stop writing the log after property"memoryPages") file with some device date.
Where did you retrieve the file main app or extension app?
Try to get the file on the main app.
How did you read the data post some code here.
I try to get it in te main app wit all kind off possible Stream Provider i can use for ios Apps. the same i already listet yesterday
the nsUrl for the ons that has to use it i created by NSUrl.FromFilename(Path I Saved the File)
I can't figure out what happened on your side without your code.
as example: NSData.FromURL( NSUrl.FromFilename("Path I Saved the File")).AsStream()
thear is no more code
If you want to create a URL from path use this:
How did you get a shared container path? Make sure your file has existed on that path using:
already tryed new NSUrl(path, false); dose change nothing.
File.Exists(path); ist true
Also
NSFileManager fileManager = NSFileManager.DefaultManager;
fileManager.Contents("Path to Saved the File").AsStream();
Did not work either
Try to get NSData first.
Can you get the expected value through
NSData.FromUrl(new NSUrl(path, false));
?I could Create the NSData but every attampt to read any bit from it after createing fails in the same crash result.
Example:
NSData data = NSData.FromUrl(new NSUrl(path, false));
data.AsStream();
NSData is not a collection we can't access it through
data[0]
. Convert it to byte array first and then access its first byte:in the same post i write that data.AsStream(); did not work, how should your example work for me? And NSData is an colection data[0]; returns an byte i use this on other applications for some reasons.
Try to provide a sample here to help me reproduce this issue.
This code worked on my side.
I only use the demo code for Share Extensions with
To try loading in the extension.
To try loading in the app itself i drag the part
if(fileManager.FileExists(NewFile))
{
NSData data = NSData.FromUrl(new NSUrl((NewFile, false));
var streams = data.AsStream();
// App Crash
}
To an simply button click in the app.
I can't figure out what will cause an exception if the file does exist on that specific path so we need your sample to help us reproduce this issue.
If you feel difficult to share it on this public forum, try to open a free support ticket here:
https://support.microsoft.com/en-us/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6
https://1drv.ms/u/s!AlyHXQLoRDospvYnrXzUsY2fNVL6rA?e=235nTv
Example app with same crash on try get stream of file
Try to check your group settings here:
Will you get a valid container?


If I comment out the shared part and retrieve the data directly it succeed:
Streams:
I get an valid container and coud not get an stream if i try to get it directly.
As info, the problem only exists on hardware devices (tested on iphone 11, 7 and 8), in an virtual devies it works
It worked as expected as I showed above on my iPhone 7 Plus using your project.