Started working with Azure Blob storage and uploading images to it from a Xamarin forms android app, the images upload with no issue both picking from the devices gallery and taking a photo and uploading it straight away. Is there anyway to upload a Signature image as well? I am using the Xamarin.Controls.SignaturePad.Forms plugin to create the signature but I don't understand how I would upload it to the blob storage the same way as a image. Do I need to convert it somehow?
Signature Code + Upload Code:
private async void SaveButton_Clicked(object sender, EventArgs e)
{
Stream image = await PadView.GetImageStreamAsync(SignatureImageFormat.Jpeg);
}
private async void UploadImage(Stream stream)
{
var account = CloudStorageAccount.Parse("Connection String + Key etc");
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference("images");
await container.CreateIfNotExistsAsync();
var name = Guid.NewGuid().ToString();
var blockBlob = container.GetBlockBlobReference($"{name}.png");
await blockBlob.UploadFromStreamAsync(stream);
await DisplayAlert("Uploaded", "Image uploaded to Blob Storage Successfully!", "OK");
}
Code From Image Upload:
private async void btnTakePic_Clicked(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":(No Camera available.)", "OK");
return;
}
else
{
_mediaFile = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
Directory = "Sample",
Name = "myImage.jpg"
});
if (_mediaFile == null) return;
imageView.Source = ImageSource.FromStream(() => _mediaFile.GetStream());
var mediaOption = new PickMediaOptions()
{
PhotoSize = PhotoSize.Medium
};
UploadedUrl.Text = "Image URL:";
}
}