With the introduction of FilePicker in Essentials we are going to retire the separate file picker plugin (github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows/). Thanks everyone for your support on that plugin!
Hello Gerald, you can see from the quick amount of questions, this is a very useful and required API , I am tryiing to get the file paths to upload to a server, however filepath returns "content://com.android.providers.media.documents/document/image%3A27" which is not working, do I need to do a string concate with the file name?
Love it that you are using it already! So, what I think you should do is copy it to a local folder first or just use the stream directly. Have a look at the Essentials sample here where I think they do that: github.com/xamarin/Essentials/blob/main/Samples/Samples/ViewModel/FilePickerViewModel.cs#L100
This is great and super easy to grab images. That said, I can't seem to find an example of how to get the file path for an image (and WHERE we would execute the code to do so). I'm trying to grab a string file path to install in a sqlite database (which will display the image in a collectionview based on the file path). I can't figure out how to do this, but it seems like it should be a simple matter of grabbing the image path and doing some data binding. Any pointers?? Thank you so much!
I'm not sure if I fully understand what you want to do. But here is one thing to consider: watch out with filepaths. Especially if you're working with images coming from the gallery. For iOS for instance, images might not be on the device but on iCloud and will be downloaded on-the-fly. Having that said; the file path is supplied as part of the picked file, right? So you should be able to work with that?
@@jfversluis Thanks for the response, I'll think on this and see what I can do. To clarify what I meant before: I'm using a SQLite database to store objects that contain textual data as well as an associated image, so I was hoping to use a file path that points to the Android photo gallery rather than convert a photo to a byte array to load into the object. I know that a string point to a web url can be used to load images in a CollectionView, so I was hoping a file path pointing to the phone's image gallery would work the same way
Gotcha! Understandable but I don’t think recommendable. With all the permissions and differences in permissions on different Android versions and vendor versions and... do I need to go on? 😅
Excellent video and good explanation .. a question please may be silly but I am new to xamarin ..... How do I show in the collectionView that the file was added? or that shows an image of the extension of it?
Very useful tutorial. Thank you. What I would like to do is populate a Picker with a list of file names (of type XSL) for a specific folder (MacOS). So I don't need a File Picker at this stage but just obtain the list of filenames in folder x and populate Picker. Is this possible? I have other questions but I deal with one at a time. Keep up the great work.
I've noticed the questions! I guess that sure is possible. Be careful with the new permissions models in Catalina. James Montemagno's StreamTimer might have some file I/O in combination with macOS. Shouldn't be different than regular System.IO in .NET
@@jfversluis Yeah - no one seems to like my questions. All downvoted. Oh well! You mention System.IO and I was just about to try that as a method. Doesn't System.IO work with MacOS? My permissions should be OK because they will be /Users/Shared//Styles/.
Thank you for the video. How can i acces the app folder returned by "Application.Context.GetExternalFilesDir(null).ToStrting()" with FilePicker on Android Device API30
Hey Gerald thanks for the video. This was really helpful. I am also trying to get all the audio files in my storage in a list but I am not able to do it with this method. Is there any other way?
Great video!! But, please I have a question, why can't I get the actual file path on my system, instead of the actual file path, I get aa.companyname..... etc
hi, I am Faisal from yemen,I am programmer in Visual Studio C# and Maui. I work in an application for issuing collection bonds to customers using the Maui application. How can I print that bond using a Bluetooth printer?
If the feature for "StorageRead" and "StorageWrite" is not supported in the documentation for my UWP app I'm making, is there any other workaround to enable permissions for accessing files on the C: drive?
If you can, you probably want to choose a different location. Have a look at this Docs page for a full explanation: docs.microsoft.com/windows/uwp/files/file-access-permissions
Hi Gerald, awesome video! I'm tryng to take a pdf instead of an image on Android but i can't show it in the Image box. It works but the image box is empty, how can i visualize it in a pdf viewer? Thank you
Thanks for the kind words Luca! You can't just show a PDF file in an Image control since it's not an image. So either you will have to open the file, which you can do with the Xamarin.Essentials Launcher for instance (docs.microsoft.com/xamarin/essentials/launcher) or incorporate your own PDF viewer. There aren't many out there, I have a blog post about it here: blog.verslu.is/xamarin/xamarin-forms-xamarin/showing-pdf-files-xamarin-forms/ or use a component like from SyncFusion, I think they have one. Hope that helps!
@@jfversluis Sorry for the double answer, but i have another question: if i want to display a .doc/.docx or .xls/.xlsxa or .txt file what object can i use?
@@gandolfyoutube1994 I think that is even a bit harder than PDF. With SyncFusion you can do it though: www.syncfusion.com/word-framework/xamarin Note that SyncFusion has a community license that you can use for free if you're not a big company :)
In order to specify per platform file type. Where can i find that? For example in windows I want to pick an exe and in android I want to pick an installed application or at least the apk file. Do i specify that as .exe for UWP and as .apk for android etc etc ? Is there a table or something with that information ?
I’m afraid there is no real list. Not that I know of at least. The iOS built-in ones are here; developer.apple.com/documentation/uniformtypeidentifiers/uttype/system_declared_types For Android You could use this to discover the mime type: developer.android.com/reference/android/webkit/MimeTypeMap Or here is a (self declared) complete list: www.sitepoint.com/mime-types-complete-list/ And for Windows you can just use the extension. Details on how to make it platform specific are here: docs.microsoft.com/xamarin/essentials/file-picker?tabs=ios#pick-file
Thanks for this video Gerald. I would like to ask if there is a way of hiding other files not included on the selected filetype? So if pdf only PDF Files will display on the selection.
Nice work - really easy to use! It would be handy to be able to initialise the FilePicker with an optional file path so it opens up the dialog at a specific location. Do you know if its possible with the current version or if it could be incorporated into a future release?
Hi, please how do you put files or images in the Android emulator for testing ? The demo works for me but there's nothing to pick in the emulator. thanks
Excellent tutorial, thanks (-_-) I have a question about the part of selecting multiple images, if I want to get from each image both the name and stream, how can I send them to the view and how can I work with them in the view?
Thank you! I think you’ll get a collection back with all the selected files, right? So loop through that :) Else I’ll need some more details about what you’re trying to do
@@jfversluis Thanks for the quick response, I was able to get the name and path of each image, but I could not pass the information to the view. I will try to detail it with code I created in GitHub github.com/DanielDanielDanielD/FilePicker-in-Xamarin/blob/main/FilePicker-in-Xamarin
I think if you have a datatemplate in your CollectionView with an Image and set the Source of the image to {binding .} it should show the image actually :)
@@jfversluis You're right, I did it on the view page and it's work for the image, but I was trying to display in DataTemplate also the name of the image. Anyway I got along with this, Thx
In that case you’ll have to create a custom object that holds that imagesource and a string and then change the template to show a label and image and set the bindings to {binding yourimageproperty} and the same for your text
Thank you Raviteja! I don’t think there is right now. Check to see if there is an issue for it or open one yourself. One way to go about it right now is to let the user open the file and then check the file size then. Not ideal in terms of UX maybe, but it’s something :)
Hi mr Gerald, I follow your videos and they are so well made and easy to understand. I have a problem with this FilePicker and I don't know why: I followed all your instructions in the video but still I get a NullPointerException at the line "var pickResult = await FilePicker.PickAsync(...)". Why this happens? It is because of permissions (but I granted them)? Can you help me?
Hi, Hope u r doing good, And i have a question here - i am able to select multiple images on the android platform, but not able to select the multiple image on iOS platform. can u pls add your comments on this
I have a custom FileType: {DevicePlatform.macOS, new[] {"xsl"} }. Is it possible to drill down further and limit with file title wild card? Eg: Elderly*.xsl?
I don't think so, not 100% sure. The concept is different than on Windows. Here you select filetypes and not so much by a filename pattern. Of course the obvious way around this is to check the incoming filename on the selected file
how to get file for mail in xamrine form bcz this path content://com.android.providers.media.documents/document/image%3A655 say that does not found filr
Have a look at this example: github.com/xamarin/Essentials/blob/main/Samples/Samples/ViewModel/FilePickerViewModel.cs#L106 You have to copy it to a local folder first
HI Gerald. I want to use FIlePicker to choose an sqlite file to be read. Somwhow Filepicker only appears after I try to open bd. How I force my app to wait until FIlepicker shows? Thanks
Sorry I don’t understand “after I try to open bd”? Do you mean your code continues executing when you try to pick the file? Are you using await to wait for the filepicker call to finish?
@@jfversluis My code does not stop when I call Filepicker . it continues. So when I need the name of the file I don't have. I have this in my code var result = await FilePicker.PickAsync();
Hi Gerald, i can't filter sqlite (.db3) files (no MIME associated) so my only option is filter all files; P.S: after calling FilePicker, if i use userDialog.AlertAsync, it doesn't show nothing! I had to call Page DisplayAlert
I love how you incorporate your 'subscribe to my channel' message in a fun way in every video! :D I really did not expect this one! Awesome video as always. - 'Well, isn't that convenient?..' :D
Hi Gerald, awesome video. Just one question , does this also work on Android X. I recently had many problem with AndroidX and Xamarin relating to accessing files other than those in gallery images because of AndroidX latest privacy settings.
Thanks for the kinda words Johan! That is a great question. I must admit I didn’t test that specifically. I will and get back to you. Do you have any more details on the problems you had? Filed any issues or anything somewhere?
@@jfversluis Yes , I cross checked my solution with github.com/CrossGeeks/MultipleMediaPickerSample Same thing happened here , on Android 8.1 Simulator the video picker works perfectly, using Android 10 Simulator (same code) then I can't access the full path name. Upgrading to AndroidX made no difference also. So the problem is on AndroidX I can't access the full pathname. I filed an issue in same repo above.
Ah, so you can’t access the path? Can you access the stream? What I’ve seen happening in the Essentials sample app for the FilePicker is that they copy the file first to a local folder within the app sandbox. Maybe that’s the way to do it? That is also how iOS does it, but there it happens automatically
@@jfversluis Thanks Gerald. There seems to be a problem In James Montemagno plugin CrossCurrentActivity. The same issue exist in Xamarin.Essentials. I will follow it up in Essentials repo. Thanks for the help anyway , much appreciated.
Hi sir Gerald please notice me i got this error "Failed to resolve Xamarin.Essentials.FileResult" if i run the program i researched it and i didnt find please help me
Is this correct for XSL files on iOS: {DevicePlatform.iOS, new[] { "com.microsoft.xsl"} } ? I am trying an iPad simulator and when the file picker displays it just says "loading'. At the moment the path is hardcoded to a folder on my Mac so I don't know it that is the problem with it just saying loading?
I changed the path temporarily to literal and removed the file type parameter and now the window displays. I can navigate to my iCloud and see all files. I just can’t work out this custom xsl parameter string. 🤔
Hi Gerald. Update! From my research it seems that Xamarin does not support XSLT transformations anyway. I could be wrong. I have asked on the Xamarin Forum. So I decided to look at the overall design of my app to see if I could do something else that still gives the user some flexibility for styles. I have come up with a WebView and setting the HtmlViewSoiurce. Currently using static HTML text to test. But it uses a pathed CSS file. That is the trick - allowing the user to select a CSS file from a drop-list picker. So I am back to my same question. I kindly ask for advice about how to filter for CSS files. I looked at all the approved file types with Adobe and the have public.html but not one for CSS. 😩
I think you need to register that extension yourself: stackoverflow.com/questions/21937978/what-are-utimportedtypedeclarations-and-utexportedtypedeclarations-used-for-on-i/50993269#50993269
@@jfversluis I did wonder that. I also came across a similar question here: stackoverflow.com/questions/4186401/how-do-i-register-a-custom-filetype-in-ios. But technically I don't want to create my own "file association". CSS is a standard file type as you know and with respects to my app the CSS file is only being used by the WebView component that is displaying the HTML content. This is why I was hoping for a more generic official file type for CSS like there is for HTML. I will investigate this in due course.
I understand that you think that and that’s how Windows works, however this is a different world 😄 iOS (at least) all works with the uttypes and as long as there isn’t one registered, it doesn’t exist. From my quick 1 minute investigation this seems to be needed
@@jfversluis Ah damn. I'm trying to do it for my final year project at college. My app will basically display DFP fiels that i have written myself. It's just to gather data, doesnt need to be fancy. I was hoping there was a way to pick files from the assests folder rather than the emulators storage. Unless I create these files on the emulator itself
@@WaveForceful Of course what you could do is copy the file from your assets to the storage in your app startup or something :) but that depends on your requirements of what you're trying to do here
@@jfversluis It's just trying to display the pages to the user really. I've basiclaly made a python guide for tutors in onenote and saved them as .pdf files. the mobile app's only job is to display them, it doesnt need to be a technical marvel. I've used a flyout app aswell.
Here is a list of built-in types for iOS: developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1 I see the Word one for iOS is com.microsoft.word.doc Here is a list of MIME types: www.sitepoint.com/mime-types-complete-list/ I see the Word one in MIME is application/msword
Hii Gerald Actually under c-programfiles-x86 Android folder is not getting created while downloading , any idea why it can happen ,means android sdk are not downloading I think
O no! I'm sorry that is happening to you :( Are you able to create another emulator maybe? You can find how to do that here: docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager?tabs=macos&pivots=windows or troubleshoot the existing one with this link: docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/troubleshooting?pivots=windows When does this happen exactly?
@@jfversluis Sorry about that. I tried to open excel file with "{ DevicePlatform.Android, new[] {"application/xlsx"} }" but it doesn't work to me. Can u tell me some solution to open excel file or get the address of excel file in emulator?
Is this the way? Picked images on variable, Create a list for the path , Then create a foreach loop through the picked image variable , Get it using the results object Is this is the method....?
Hi Raffi! Thanks for your suggestion! I feel like that is a biiiiig topic to cover though :D Do you have any specific service in mind? Because this will need infrastructure on the server-side as well. I'd really like to help you out, but I don't think I can make it happen
@@jfversluis Hi Gerald Thanks for your reply .I am developing one app that needs appa to app call .If you have time please take this topic and do a video for this.still now I don't know how to create App to app call I am searching in google but I don't find a good solution ..if you know any about this please ping me
I was just scrolling over this comment, did you see the Azure Media Services that are announced? Looks like you can do it with that azure.microsoft.com/services/media-services/
@@jfversluis I have found one solution in www.frozenmountain.com/products-services/icelink/ but i dont know how to implement this.Please see this if you have time
Hey Great Video, I am using Media Picker to take photo using camera. I am good with it but somehow it rotates the image.Any fix for that. async void ImageButton_Clicked(object sender, EventArgs e) { IsBusy = true;
var result = await MediaPicker.CapturePhotoAsync(); await LoadPhotoAsync(result); IsBusy = false; } async Task LoadPhotoAsync(FileResult photo) { // canceled if (photo == null) { return; } var stream = await photo.OpenReadAsync(); ProfileImage.Source = ImageSource.FromStream(() => stream);
var content = new MultipartFormDataContent(); content.Add(new StreamContent(await photo.OpenReadAsync()), "photo", photo.FileName); content.Add(new StringContent("1"), "RegID"); var httpClient = new HttpClient(); var response = await httpClient.PostAsync("serverURL", content); }
The FileResult has a FullPath property: docs.microsoft.com/dotnet/api/xamarin.essentials.filebase.fullpath?view=xamarin-essentials#Xamarin_Essentials_FileBase_FullPath
Hey there, this is a great tutorial! I am currently trying to create an android app and wish to have an insert multiple image function. However, I have received the following problem when I run the emulator and am currently stuck here: The application is in break mode: Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code). System.TypeLoadException: 'Could not load type of field 'App5.Views.Image_Sharing.InsertImage+d__2:5__1' (5) due to: Could not resolve type with token 01000078 from typeref (expected class 'Xamarin.Essentials.FileResult' in assembly 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Xamarin.Essentials.FileResult member:(null)'
Thank you! Hm this error typically happens when there are different versions of Essentials installed on you shared project and the Android project. Could you double check that?
@@jfversluisyes, also how to cancel the api call. Cos i dont know the best practice to cancel it on my page if i back to previous page, meanwhile the api call is still processing the request and wait for the result on background thread.
@@jfversluis after updated xamarine.Essentials 1.6.9 pre than write tha code in my project then not woking PickAsync and PickMultipleAsync method its given error say that does not contain a defination for PickAsync plz help i want to purchase this plugin
Can you find my email on my GitHub profile and send me some more details? What does the code look like and what is the exact error? Then we’ll figure it out :)
With the introduction of FilePicker in Essentials we are going to retire the separate file picker plugin (github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows/). Thanks everyone for your support on that plugin!
Hello Gerald, you can see from the quick amount of questions, this is a very useful and required API , I am tryiing to get the file paths to upload to a server, however filepath returns "content://com.android.providers.media.documents/document/image%3A27" which is not working, do I need to do a string concate with the file name?
Love it that you are using it already! So, what I think you should do is copy it to a local folder first or just use the stream directly. Have a look at the Essentials sample here where I think they do that: github.com/xamarin/Essentials/blob/main/Samples/Samples/ViewModel/FilePickerViewModel.cs#L100
@@jfversluis var copyPath = Path.Combine(FileSystem.CacheDirectory, image.FileName); OMG this is the answer I was looking for!!! thank you
@@sipepguru Woohoo! Glad you figured it out!
Awesome, was having trouble figuring this out, thanks!
@@Soda-js2vx Seems like I should do a follow up video for this :)
This is great and super easy to grab images. That said, I can't seem to find an example of how to get the file path for an image (and WHERE we would execute the code to do so). I'm trying to grab a string file path to install in a sqlite database (which will display the image in a collectionview based on the file path). I can't figure out how to do this, but it seems like it should be a simple matter of grabbing the image path and doing some data binding. Any pointers?? Thank you so much!
I'm not sure if I fully understand what you want to do. But here is one thing to consider: watch out with filepaths. Especially if you're working with images coming from the gallery. For iOS for instance, images might not be on the device but on iCloud and will be downloaded on-the-fly. Having that said; the file path is supplied as part of the picked file, right? So you should be able to work with that?
@@jfversluis Thanks for the response, I'll think on this and see what I can do. To clarify what I meant before: I'm using a SQLite database to store objects that contain textual data as well as an associated image, so I was hoping to use a file path that points to the Android photo gallery rather than convert a photo to a byte array to load into the object. I know that a string point to a web url can be used to load images in a CollectionView, so I was hoping a file path pointing to the phone's image gallery would work the same way
Gotcha! Understandable but I don’t think recommendable. With all the permissions and differences in permissions on different Android versions and vendor versions and... do I need to go on? 😅
Excellent video and good explanation .. a question please may be silly but I am new to xamarin ..... How do I show in the collectionView that the file was added? or that shows an image of the extension of it?
What do you want to show exactly?
@@jfversluis Thank you
Very useful tutorial. Thank you. What I would like to do is populate a Picker with a list of file names (of type XSL) for a specific folder (MacOS). So I don't need a File Picker at this stage but just obtain the list of filenames in folder x and populate Picker. Is this possible? I have other questions but I deal with one at a time. Keep up the great work.
I've noticed the questions! I guess that sure is possible. Be careful with the new permissions models in Catalina. James Montemagno's StreamTimer might have some file I/O in combination with macOS. Shouldn't be different than regular System.IO in .NET
@@jfversluis Yeah - no one seems to like my questions. All downvoted. Oh well! You mention System.IO and I was just about to try that as a method. Doesn't System.IO work with MacOS? My permissions should be OK because they will be /Users/Shared//Styles/.
@@jfversluis Look here: forums.xamarin.com/discussion/140069/how-can-i-get-a-list-of-all-local-files-in-a-directory Seems like I can use System.IO.
@@jfversluis Resolved. 😊
Thank you for the video.
How can i acces the app folder returned by "Application.Context.GetExternalFilesDir(null).ToStrting()" with FilePicker on Android Device API30
Hey Gerald thanks for the video. This was really helpful. I am also trying to get all the audio files in my storage in a list but I am not able to do it with this method. Is there any other way?
Great video!! But, please I have a question, why can't I get the actual file path on my system, instead of the actual file path, I get aa.companyname..... etc
That's how mobile operating systems work. Your app is in a sandbox and is not just allowed to go through your whole filesystem typically :)
hi, I am Faisal from yemen,I am programmer in Visual Studio C# and Maui. I work in an application for issuing collection bonds to customers using the Maui application. How can I print that bond using a Bluetooth printer?
If the feature for "StorageRead" and "StorageWrite" is not supported in the documentation for my UWP app I'm making, is there any other workaround to enable permissions for accessing files on the C: drive?
If you can, you probably want to choose a different location. Have a look at this Docs page for a full explanation: docs.microsoft.com/windows/uwp/files/file-access-permissions
Hi Gerald, awesome video! I'm tryng to take a pdf instead of an image on Android but i can't show it in the Image box. It works but the image box is empty, how can i visualize it in a pdf viewer?
Thank you
Thanks for the kind words Luca!
You can't just show a PDF file in an Image control since it's not an image. So either you will have to open the file, which you can do with the Xamarin.Essentials Launcher for instance (docs.microsoft.com/xamarin/essentials/launcher) or incorporate your own PDF viewer. There aren't many out there, I have a blog post about it here: blog.verslu.is/xamarin/xamarin-forms-xamarin/showing-pdf-files-xamarin-forms/ or use a component like from SyncFusion, I think they have one.
Hope that helps!
@@jfversluis Thank you for the answer!! I will check soon and i will let you know! Have a good night!
@@jfversluis Sorry for the double answer, but i have another question: if i want to display a .doc/.docx or .xls/.xlsxa or .txt file what object can i use?
@@gandolfyoutube1994 I think that is even a bit harder than PDF. With SyncFusion you can do it though: www.syncfusion.com/word-framework/xamarin
Note that SyncFusion has a community license that you can use for free if you're not a big company :)
In order to specify per platform file type. Where can i find that? For example in windows I want to pick an exe and in android I want to pick an installed application or at least the apk file. Do i specify that as .exe for UWP and as .apk for android etc etc ? Is there a table or something with that information ?
I’m afraid there is no real list. Not that I know of at least. The iOS built-in ones are here; developer.apple.com/documentation/uniformtypeidentifiers/uttype/system_declared_types
For Android You could use this to discover the mime type: developer.android.com/reference/android/webkit/MimeTypeMap
Or here is a (self declared) complete list: www.sitepoint.com/mime-types-complete-list/
And for Windows you can just use the extension. Details on how to make it platform specific are here: docs.microsoft.com/xamarin/essentials/file-picker?tabs=ios#pick-file
@@jfversluis Thank you very much for your quick response. Didn't expect this :)
Of course! No problem! That’s why I’m here :)
Thanks for this video Gerald. I would like to ask if there is a way of hiding other files not included on the selected filetype? So if pdf only PDF Files will display on the selection.
This uses whatever the OS offers so if it doesn’t do that then there is no way to hide it with this plug-in
Nice work - really easy to use! It would be handy to be able to initialise the FilePicker with an optional file path so it opens up the dialog at a specific location. Do you know if its possible with the current version or if it could be incorporated into a future release?
Oh that would be handy! That is not in there now, but might be worth opening an issue for :)
Hi, please how do you put files or images in the Android emulator for testing ? The demo works for me but there's nothing to pick in the emulator. thanks
Did you try simply drag and dropping it on the emulator? ;)
@@jfversluis It works, thank you
Hi Gerald, how to store multiple pdfs. Same as you do with multiple images. I mean what will be the list type for pdfs?
Hey Shubham! You should be able to just do the same with PDFs indeed. I'm not sure what you mean with "list type for PDFs"?
Have you done a video on being able to drag and drop file like many Mac apps do?
Specifically for Mac? No. That will definitely involve platform-specific code at this point :)
Hi thank for this videos, is it possible te read a file text with filepicker ?
You can sure pick one, reading and getting contents should be done after that :)
Excellent tutorial, thanks
(-_-)
I have a question about the part of selecting multiple images, if I want to get from each image both the name and stream, how can I send them to the view and how can I work with them in the view?
Thank you! I think you’ll get a collection back with all the selected files, right? So loop through that :)
Else I’ll need some more details about what you’re trying to do
@@jfversluis Thanks for the quick response,
I was able to get the name and path of each image, but I could not pass the information to the view.
I will try to detail it with code I created in GitHub
github.com/DanielDanielDanielD/FilePicker-in-Xamarin/blob/main/FilePicker-in-Xamarin
I think if you have a datatemplate in your CollectionView with an Image and set the Source of the image to {binding .} it should show the image actually :)
@@jfversluis You're right, I did it on the view page and it's work for the image, but I was trying to display in DataTemplate also the name of the image. Anyway I got along with this, Thx
In that case you’ll have to create a custom object that holds that imagesource and a string and then change the template to show a label and image and set the bindings to {binding yourimageproperty} and the same for your text
Is there an explanation about you said of : Not having async void methods ? ... Why not, Thank You !
You probably want to have a look at this to get a better understanding of all of it: github.com/brminnick/AsyncAwaitBestPractices
Thank you very much ♥ ️
But I want to ask you something
Is he getting all the data for a picture file
Not sure if I understand what you’re asking, but you get all the bytes of the image so you can do whatever you want with it :)
Hey Gerald, great video. One question, are there any options provided to restrict the file size?
Thank you Raviteja! I don’t think there is right now. Check to see if there is an issue for it or open one yourself.
One way to go about it right now is to let the user open the file and then check the file size then. Not ideal in terms of UX maybe, but it’s something :)
Thank you Gerald. You're the Best. Question: How can i upload the files to server (just the files selected) ?
See answer on the other thread
Hi mr Gerald, I follow your videos and they are so well made and easy to understand.
I have a problem with this FilePicker and I don't know why:
I followed all your instructions in the video but still I get a NullPointerException at the line "var pickResult = await FilePicker.PickAsync(...)". Why this happens? It is because of permissions (but I granted them)? Can you help me?
Damn I figured out, the NuGet Package need to be initialized in the OnCreate() in the .Droid solution. Ok now it works!
Glad you found it!
Great example, bro. I still have a doubt, could i use it for .txt files?
Absolutely!
Hi, Hope u r doing good, And i have a question here - i am able to select multiple images on the android platform, but not able to select the multiple image on iOS platform. can u pls add your comments on this
Should work as far as I know :)
Thanks!!
Have some example to show local Pdf (Pdf viewer)
Yep! Save and Show PDF Files with This Library in Xamarin.Forms
ua-cam.com/video/FqetV1Lh-9c/v-deo.html
Hi Gerald, can you pls. explain how to share PDF files to other Apps.
Did you have a look at the Share functionality also in Essentials?
hi
Gerald Versluis Thanks for the Vedio Can you please provide the demo for uploading the file using FilePicker....
Check out this video for uploading it: ua-cam.com/video/KPDGtLeNClQ/v-deo.html
@@jfversluis Hi I need to upload Pdf or any type of file using FilePicker in Android
can you Please provide it
If you combine the code from those two videos you should have exactly that
@@jfversluis i have send it through API ... I am new to this Please help me out in File Uploading (PDF)
Hi, thank you so much for your help! We don't unfortunately usually find good help for Xamarin tutos online.
Glad I am able to provide some! Which resources do you know of? Maybe I can provide you with some additional ones!
@@jfversluis I just faced a problem on the OpenReadAsync... can you please help me with it on insta, by mail or by whatsapp?
I have a custom FileType: {DevicePlatform.macOS, new[] {"xsl"} }. Is it possible to drill down further and limit with file title wild card? Eg: Elderly*.xsl?
I don't think so, not 100% sure. The concept is different than on Windows. Here you select filetypes and not so much by a filename pattern. Of course the obvious way around this is to check the incoming filename on the selected file
how to get file for mail in xamrine form bcz this path content://com.android.providers.media.documents/document/image%3A655 say that does not found filr
Have a look at this example: github.com/xamarin/Essentials/blob/main/Samples/Samples/ViewModel/FilePickerViewModel.cs#L106
You have to copy it to a local folder first
Hi All,
Can you please guide me if the user wants to open the "Gallery" Folder rather than the "Recent" folder.?
I don't think that is something you can specify with this API
Is there any way to select only the folder path? I'm developing an app where the user must select a folder first before saving the files.
I don’t think that is in there right now
@@jfversluis I hope it'll be included soon.
HI Gerald. I want to use FIlePicker to choose an sqlite file to be read. Somwhow Filepicker only appears after I try to open bd. How I force my app to wait until FIlepicker shows? Thanks
Sorry I don’t understand “after I try to open bd”? Do you mean your code continues executing when you try to pick the file? Are you using await to wait for the filepicker call to finish?
@@jfversluis My code does not stop when I call Filepicker . it continues. So when I need the name of the file I don't have. I have this in my code var result = await FilePicker.PickAsync();
Hi Gerald, i can't filter sqlite (.db3) files (no MIME associated) so my only option is filter all files; P.S: after calling FilePicker, if i use userDialog.AlertAsync, it doesn't show nothing! I had to call Page DisplayAlert
I think you can still filter on it, but you have to register your own MIME type thing for that
How to pick doc/docx only files?
You’re able to specify certain extensions and file types as I show in the video :)
Hi, can we use Expansion Files in Xamarin or Xamarin.Forms?
What are expansion files? :)
It seems you can: applandeo.com/blog/5-steps-using-expansion-files-android-xamarin-forms/
Didn't hear of this, thanks! I learned something today :)
I love how you incorporate your 'subscribe to my channel' message in a fun way in every video! :D I really did not expect this one! Awesome video as always.
- 'Well, isn't that convenient?..' :D
Haha thanks! This way I don't have to add the annoying animation in there and try to incorporate some fun at the same time :)
Hello bro. Its possible open a pdf file using FilePicker from internal storage, i would like a video step to step
What is not clear from this video? :) I think this should get you a long way there
Hi Gerald, awesome video. Just one question , does this also work on Android X. I recently had many problem with AndroidX and Xamarin relating to accessing files other than those in gallery images because of AndroidX latest privacy settings.
Thanks for the kinda words Johan!
That is a great question. I must admit I didn’t test that specifically. I will and get back to you. Do you have any more details on the problems you had? Filed any issues or anything somewhere?
@@jfversluis Yes , I cross checked my solution with github.com/CrossGeeks/MultipleMediaPickerSample Same thing happened here , on Android 8.1 Simulator the video picker works perfectly, using Android 10 Simulator (same code) then I can't access the full path name. Upgrading to AndroidX made no difference also. So the problem is on AndroidX I can't access the full pathname. I filed an issue in same repo above.
Ah, so you can’t access the path? Can you access the stream? What I’ve seen happening in the Essentials sample app for the FilePicker is that they copy the file first to a local folder within the app sandbox. Maybe that’s the way to do it? That is also how iOS does it, but there it happens automatically
@@jfversluis Thanks Gerald. There seems to be a problem In James Montemagno plugin CrossCurrentActivity. The same issue exist in Xamarin.Essentials. I will follow it up in Essentials repo. Thanks for the help anyway , much appreciated.
Oooh interesting! Make sure to tag me there if needed :) and my pleasure! Hope you’re liking the content and let me know if you need anything else
Hi sir Gerald please notice me i got this error "Failed to resolve Xamarin.Essentials.FileResult" if i run the program i researched it and i didnt find please help me
Make sure you installed the same version of Essentials on all of your projects
Is this correct for XSL files on iOS: {DevicePlatform.iOS, new[] { "com.microsoft.xsl"} } ? I am trying an iPad simulator and when the file picker displays it just says "loading'. At the moment the path is hardcoded to a folder on my Mac so I don't know it that is the problem with it just saying loading?
I changed the path temporarily to literal and removed the file type parameter and now the window displays. I can navigate to my iCloud and see all files. I just can’t work out this custom xsl parameter string. 🤔
Hi Gerald. Update! From my research it seems that Xamarin does not support XSLT transformations anyway. I could be wrong. I have asked on the Xamarin Forum. So I decided to look at the overall design of my app to see if I could do something else that still gives the user some flexibility for styles. I have come up with a WebView and setting the HtmlViewSoiurce. Currently using static HTML text to test. But it uses a pathed CSS file. That is the trick - allowing the user to select a CSS file from a drop-list picker. So I am back to my same question. I kindly ask for advice about how to filter for CSS files. I looked at all the approved file types with Adobe and the have public.html but not one for CSS. 😩
I think you need to register that extension yourself: stackoverflow.com/questions/21937978/what-are-utimportedtypedeclarations-and-utexportedtypedeclarations-used-for-on-i/50993269#50993269
@@jfversluis I did wonder that. I also came across a similar question here: stackoverflow.com/questions/4186401/how-do-i-register-a-custom-filetype-in-ios. But technically I don't want to create my own "file association". CSS is a standard file type as you know and with respects to my app the CSS file is only being used by the WebView component that is displaying the HTML content. This is why I was hoping for a more generic official file type for CSS like there is for HTML. I will investigate this in due course.
I understand that you think that and that’s how Windows works, however this is a different world 😄 iOS (at least) all works with the uttypes and as long as there isn’t one registered, it doesn’t exist. From my quick 1 minute investigation this seems to be needed
How do you pick a file that is stored in the assests folder?.
Not sure if that is possible tbh, because that lives inside of your app sandbox
@@jfversluis Ah damn. I'm trying to do it for my final year project at college. My app will basically display DFP fiels that i have written myself. It's just to gather data, doesnt need to be fancy.
I was hoping there was a way to pick files from the assests folder rather than the emulators storage.
Unless I create these files on the emulator itself
@@WaveForceful Of course what you could do is copy the file from your assets to the storage in your app startup or something :) but that depends on your requirements of what you're trying to do here
@@jfversluis It's just trying to display the pages to the user really.
I've basiclaly made a python guide for tutors in onenote and saved them as .pdf files. the mobile app's only job is to display them, it doesnt need to be a technical marvel.
I've used a flyout app aswell.
Hello. Extension for word documents??? Android="application/msword" ??? IOS="ms-word" ???
Here is a list of built-in types for iOS: developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1
I see the Word one for iOS is com.microsoft.word.doc
Here is a list of MIME types: www.sitepoint.com/mime-types-complete-list/
I see the Word one in MIME is application/msword
application/vnd.openxmlformats-officedocument.wordprocessingml.document
Hii Gerald
Actually under c-programfiles-x86 Android folder is not getting created while downloading , any idea why it can happen ,means android sdk are not downloading I think
O no! I'm sorry that is happening to you :( Are you able to create another emulator maybe? You can find how to do that here: docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager?tabs=macos&pivots=windows or troubleshoot the existing one with this link: docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/troubleshooting?pivots=windows When does this happen exactly?
I do the same to open my excel file but it doesn't work. Can you recommend some solution for this problem ?
“It doesn’t work” isn’t very specific, that makes it hard to solve :)
@@jfversluis Sorry about that. I tried to open excel file with "{ DevicePlatform.Android, new[] {"application/xlsx"} }" but it doesn't work to me. Can u tell me some solution to open excel file or get the address of excel file in emulator?
@@minhchi1134 what is doesn’t work in this case? It doesn’t show up? Do you see it but is it greyed out?
Also the actual mime type seems to be different: filext.com/faq/office_mime_types.html
@@jfversluis thanks for your help, it fixed my problem. It show up but it's greyed out. Your tutorial video is also great , it helps me alot ♥
Hey bro. thank you for this video. Could you to do a video opening a pdf file, step to step
Here you go: ua-cam.com/video/FqetV1Lh-9c/v-deo.html
How to get each file path and each picked file data aray...?
Loop through the results and get it from the resulting object :)
Is this the way?
Picked images on variable,
Create a list for the path ,
Then create a foreach loop through the picked image variable ,
Get it using the results object
Is this is the method....?
Hi please tell me how to make app to app VoIP video and audio calls using Xamarin Forms
Hi Raffi! Thanks for your suggestion! I feel like that is a biiiiig topic to cover though :D Do you have any specific service in mind? Because this will need infrastructure on the server-side as well. I'd really like to help you out, but I don't think I can make it happen
@@jfversluis Hi Gerald Thanks for your reply .I am developing one app that needs appa to app call .If you have time please take this topic and do a video for this.still now I don't know how to create App to app call I am searching in google but I don't find a good solution ..if you know any about this please ping me
I was just scrolling over this comment, did you see the Azure Media Services that are announced? Looks like you can do it with that azure.microsoft.com/services/media-services/
@@jfversluis Thank you very much ..I will check this ...if you have time please make a video about this
@@jfversluis I have found one solution in www.frozenmountain.com/products-services/icelink/
but i dont know how to implement this.Please see this if you have time
Any idea when 1.6 will be officially released?
I don't think they have a very fixed schedule. Seeing from the history releases can come quite quickly, so I would expect in the next couple of weeks
Can not selects image from photos folder of device on ios?
Hey Great Video, I am using Media Picker to take photo using camera. I am good with it but somehow it rotates the image.Any fix for that.
async void ImageButton_Clicked(object sender, EventArgs e)
{
IsBusy = true;
var result = await MediaPicker.CapturePhotoAsync();
await LoadPhotoAsync(result);
IsBusy = false;
}
async Task LoadPhotoAsync(FileResult photo)
{
// canceled
if (photo == null)
{
return;
}
var stream = await photo.OpenReadAsync();
ProfileImage.Source = ImageSource.FromStream(() => stream);
var content = new MultipartFormDataContent();
content.Add(new StreamContent(await photo.OpenReadAsync()), "photo", photo.FileName);
content.Add(new StringContent("1"), "RegID");
var httpClient = new HttpClient();
var response = await httpClient.PostAsync("serverURL", content);
}
Either rotate the image yourself manually or use the MediaPicker plugin for now which has a method for rotating built-in :)
How to get the full path using filepicker.
The FileResult has a FullPath property: docs.microsoft.com/dotnet/api/xamarin.essentials.filebase.fullpath?view=xamarin-essentials#Xamarin_Essentials_FileBase_FullPath
Hey there, this is a great tutorial!
I am currently trying to create an android app and wish to have an insert multiple image function.
However, I have received the following problem when I run the emulator and am currently stuck here:
The application is in break mode: Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).
System.TypeLoadException: 'Could not load type of field 'App5.Views.Image_Sharing.InsertImage+d__2:5__1' (5) due to: Could not resolve type with token 01000078 from typeref (expected class 'Xamarin.Essentials.FileResult' in assembly 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Xamarin.Essentials.FileResult member:(null)'
Thank you! Hm this error typically happens when there are different versions of Essentials installed on you shared project and the Android project. Could you double check that?
@@jfversluis Thank you so much! I went to check and realized that I did not update the essentials under the android project
Well there you go! Glad I could help 😄
sir can you make a video ' upload imeage with sqlite database '
What do you want to do with the SQLite database?
I believe that something supper useful would be how to send that pdf or image to any web service
Did you see my video about uploading files? :)
@@jfversluis oh sir Gerald u always so wise and kind ty I'll check it out
Thanks, the issue i faced about attaching file into smtp mailing was fixed by using the code @7:35 mark, ua-cam.com/video/4gV9ZV61rn4/v-deo.html
Nice work !
Thank you Marthin! You have any suggestions for other topics?
@@jfversluis How to handle api call when navigating a page (best practice).
@@marthinch So, you mean when you go to a new page and you need to load data from an API?
@@jfversluisyes, also how to cancel the api call. Cos i dont know the best practice to cancel it on my page if i back to previous page, meanwhile the api call is still processing the request and wait for the result on background thread.
Why is th FullPath ridiculous and not usable!?
Why do you think its unusable?
@@jfversluis its not usable by Java.IO.File
Ex: the maximum number of selectable files is 5
I want to set the maximum possible value for it.
var result = await FilePicker.PickMultipleAsync(new PickOptions
{
PickerTitle = "Select file(s)"
});
if (result != null)
{
List fileList = new List();
if (Files != null && Files.Count > 0)
{
fileList = Files;
}
foreach (var file in result)
{
fileList.Add(file);
}
if (fileList != null && fileList.Count > 5)
{
ResponseModel.ErrorMessage = "Please select 5 files";
ShowPopup = true;
isError = true;
}
else
fillFiles(fileList);
}
Also now check out this plugin ua-cam.com/video/8JvgnlHVyrI/v-deo.html
awesome video but not working this method (PickAsync)
Thank you! What is not working? Do you get any error?
@@jfversluis after updated xamarine.Essentials 1.6.9 pre than write tha code in my project then not woking PickAsync and PickMultipleAsync method its given error say that does not contain a defination for PickAsync plz help i want to purchase this plugin
1.6.0 pre
Can you find my email on my GitHub profile and send me some more details? What does the code look like and what is the exact error? Then we’ll figure it out :)
@@jfversluis var PickResult = await FilePcker.PickAsync(some...) PickAsync is not working.. does not geting ur email
Awesome!
Thanks!
helpful
Great!
very thk :)
You're welcome!