I am having a problem getting an image picked by the Xam.Media.Plugin to upload to Azure. I am able to push other images to Azure, but not if I cannot when the image is selected. The first byteData line works for the static images. The current setup gives error: Cannot convert from 'Xamarin.Forms.ImageSource' to 'string' For example. I a can upload that if I used a static image like the first byteData example.
//WORKS byteData = Convert.ToByteArray("MBZ.article_image_3.jpg");
//NOT WORKS var Pic = ImageSource.FromFile(file.Path);
//NOT WORKS byteData = Convert.ToByteArray(Pic);
//NOT WORKS byteData = Convert.ToByteArray(image.Source);
//NOT WORKS byteData = image.Source;
byteData = Convert.ToByteArray(image.Source);
// await DisplayAlert("File Location", file.Path, "OK");
imageToUpload.Source = ImageSource.FromStream(() => new MemoryStream(byteData));
uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(byteData));
image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});