Studyxnet / FilePicker-Plugin-for-Xamarin-and-Windows

FilePicker Plugin for Xamarin and Windows
MIT License
74 stars 52 forks source link

Xamarin IOS unable to get selected file #62

Closed sandeepams closed 6 years ago

sandeepams commented 6 years ago

Hi @jfversluis , I've installed filepicker control from Nuget and added tried adding reference from MonoTouch10 folder and later from github to my xamarin.ios project.

  1. FileData file = await CrossFilePicker.Current.PickFile();
  2. if (file != null) { }

this is the code i added to my browse button, after selecting a file from iCloud drive, control never comes to 2. if condition.

and again when i click on browse button for second time, app crashes saying "only one operation can be active at a time".

sandeepams commented 6 years ago

Hi @rafaelrmou, can u help me finding the solution for the above issue.

ismailsameer12 commented 6 years ago

hi sandeepams, correctly,i can't say this issue.. please use try and catch and you can see that kind of issues and solve them. if you can't solve that issue please let me know that

iupchris10 commented 6 years ago

Which version of iOS SDK are you using? The iOS 11 SDK has deprecated the DidPickDocument callback, which may be the cause of this issue. This likely needs fixed in the plugin to support the new callback.

sandeepams commented 6 years ago

I customized in plugin, like

Used "DocumentPicker_DidPickDocumentAtUrls" event instead of "DocumentPicker_DidPickDocument". while returning selected file used

new FileData(e.FilePath, e.FileName, () => { var url = new Foundation.NSUrl(e.FilePath); return new FileStream(url.Path, FileMode.Open, FileAccess.Read); }) This solved my issue Thanks.

carl-neng commented 6 years ago

Hi @sandeepams Can you show the details about event instead of "DocumentPicker_DidPickDocument". while returning selected file used. Thank you advance.

sandeepams commented 6 years ago

Hi @carl-neng, check this link below, this is the customized version of existing plugin code, please not the changes are mentioned in my above post.. Just open the solution, rebuild the IOS project and copy the dlls(Plugin.FilePicker.Abstractions && Plugin.FilePicker) to your project.

FilePicker-Plugin-for-Xamarin-and-Windows-master.zip

if this is not clear, please let me know, i'm happy in helping you.

carl-neng commented 6 years ago

Hi @sandeepams Thank you so much now it working fine.

carl-neng commented 6 years ago

Hi @sandeepams When i'm using this dlls(Plugin.FilePicker.Abstractions && Plugin.FilePicker) I have problem with PNG file when I'm try to pickfile. It is show me don't have DataArray(byte). Please help to this issue. Thank you ---- FileName --- image

---- Debug Error ----- image

sandeepams commented 6 years ago

Hi @carl-neng , just in case, could u please check the plugin code you r generating these dlls. in FilePickerImplementation.cs file, under TakeMediaAsync() method make sure the handler code implemented this way.

Handler = (s, e) => { var tcs = Interlocked.Exchange(ref _completionSource, null); tcs?.SetResult(new FileData(e.FilePath, e.FileName, () => { var url = new Foundation.NSUrl(e.FilePath); return new FileStream(url.Path, FileMode.Open, FileAccess.Read); })); };

carl-neng commented 6 years ago

Hi @sandeepams Yes exactly, I use like this. Because I has been downloaded your sample you give with zip file. And I'm try use it again..... so what can do please help.

image

sandeepams commented 6 years ago

@carl-neng , only issue is with PNG files? strange it worked in my device.

carl-neng commented 6 years ago

Hi @sandeepams Yes sure, and have problem when we selected the same file for two time.

sandeepams commented 6 years ago

@carl-neng , Today also i tested my app, accepting PNG files and accepting same file multiple times, may be rebuild issue of plugin. could you please try clean rebuild plugin and import new dlls?

jfversluis commented 6 years ago

This should now be working in this NuGet: https://www.nuget.org/packages/Xamarin.Plugin.FilePicker/1.4.0-beta

If not, please open a issue on the new repo where development will be continued: https://github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows/issues