Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to store and load a MediaFile from the "MediaPlugin" TakePhotoAsync method?

Tom92Tom92 USMember ✭✭
edited April 2018 in Xamarin.Forms


I integrated the "MediaPlugin" and "PCLStorage" to my Forms Project.
The Cam App is opening and I get a MediaFile from the "TakePhotoAsync()" method.
The Path of the File is the private folder of this app, so for me something like "...ID of the App..../Documents/Pictures/" (Xamarin.Forms iOS)

But this file isnt stored persistent, its only a temporary file, right?

My idea then was to store the temp MediaFile from the "TakePhotoAsync()" method with the PCLStorage Plugin.
But with this its only possible to create a new file and store text or bytes in it, but not to store a existing file (the MediaFile)...

So how do I store this file persistent in the private app folder
and later load all stored images from there (for my own Gallery Page)?

Here is how my method looks like:
var tmpFile = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "Pictures", Name = "picture" + DateTime.Now + ".jpg", DefaultCamera = CameraDevice.Rear, SaveToAlbum = true, AllowCropping = true, SaveMetaData = true });

P.S: I know there is a copy of this file created in the album, but I want to use the private app folder so the user cant see the pictures without my GalleryPage implementation.


Sign In or Register to comment.