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

Tom92Tom92 USMember ✭✭
edited April 2018 in Xamarin.Forms

Hi,

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.

Answers

Sign In or Register to comment.