Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin.Forms.Imagesource to Azure Stream

$
0
0

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;
        });

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>