I'm using the Media plugin v3.0.1 from James Montemagno for the first time, and I'm quite confused about how it stores and retrieves photos.
Right now I'm questioning the iOS side (I'll worry about Android later).
Here's my basic code:
async void ShowCamera()
{
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert(App.alertTitle, ":( No camera available.", "OK");
return;
}
var xFile = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
SaveToAlbum = true //,
//Directory = "Sample",
//Name = "test.jpg"
});
if (xFile == null)
return;
Debug.WriteLine("********** NEW PHOTO image:" + xFile);
//adds pic to grid on the page
AddPicToGrid(xFile.Path);
xFile.Dispose();
}
async void ShowPhotoPicker(object sender, EventArgs e)
{
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await DisplayAlert(App.alertTitle, ":( Permission not granted to photos.", "OK");
return;
}
var xFile = await CrossMedia.Current.PickPhotoAsync();
if (xFile == null)
return;
Debug.WriteLine("********** PICKED image:" + xFile);
//adds pic to grid on the page
AddPicToGrid(xFile.Path);
xFile.Dispose();
}
Here are my situations and question:
1) When I call ShowPhotoPicker, and then select an image from my Library, I get a path like this:
/var/mobile/Containers/Data/Application/A1D9636A-1DEE-4E3D-9314-EAD86EA4DC7D/Documents/temp/IMG_20171010_170414.jpg
/var/mobile/Containers/Data/Application/A1D9636A-1DEE-4E3D-9314-EAD86EA4DC7D/Documents/IMG_20171010_170426.jpg
which seems to be dependent upon my app, and specifically, the instance of my app (if I rebuild, the string changes).
When this happens, I cannot reference the same photo from my library anymore because the app string has changed.
2) When I call ShowCamera, after taking a photo, a similar thing happens as in Q1.
While the image is saved into my Library as expected, I can not reference it again if I rebuild my app.
3) I do not want to change and save photos to my app local path - saving/retrieving from the Library is my desired method.
So - How can I reference a photo in my library that is not "app build based" but is instead persistent with a 'fixed' path?