async void OnUploadImageButtonClicked(object sender, EventArgs e) { activityIndicator.IsRunning = true; uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(byteData)); uploadButton.IsEnabled = false; downloadButton.IsEnabled = true; activityIndicator.IsRunning = false; }
async void OnUploadButtonClicked(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(uploadEditor.Text)) { activityIndicator.IsRunning = true; var byteData = Encoding.UTF8.GetBytes(uploadEditor.Text); uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Text, new MemoryStream(byteData)); downloadButton.IsEnabled = true; activityIndicator.IsRunning = false; } }
async void OnUploadImageButtonClicked(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(nomeFile.Text)) { DialogService.ShowLoading(Strings.AddImage); uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(byteData), nomeFile.Text); uploadButton.IsEnabled = false; DialogService.HideLoading(); DialogService.ShowSuccess(Strings.MomentSent); } else { DialogService.ShowError(Strings.ErroreUploadImmagineNoText); } }
public ImageFileUploaderPageCS() { var imageToUpload = new Image(); var downloadedImage = new Image(); var activityIndicator = new ActivityIndicator(); var downloadButton = new Button { Text = "Download Image", IsEnabled = false }; downloadButton.Clicked += async(sender, e) => { if (!string.IsNullOrWhiteSpace(uploadedFilename)) { activityIndicator.IsRunning = true; var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, uploadedFilename); downloadedImage.Source = ImageSource.FromStream(() => new MemoryStream(imageData)); activityIndicator.IsRunning = false; } }; var uploadButton = new Button { Text = "Upload Image" }; uploadButton.Clicked += async(sender, e) => { activityIndicator.IsRunning = true; uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(byteData)); uploadButton.IsEnabled = false; downloadButton.IsEnabled = true; activityIndicator.IsRunning = false; }; #if __IOS__ byteData = Convert.ToByteArray("FileUploader.iOS.waterfront.jpg"); #endif #if __ANDROID__ byteData = Convert.ToByteArray("FileUploader.Droid.waterfront.jpg"); #endif #if WINDOWS_UWP byteData = Convert.ToByteArray("FileUploader.UWP.waterfront.jpg"); #endif imageToUpload.Source = ImageSource.FromStream(() => new MemoryStream(byteData)); Title = "Upload Image"; Icon = "csharp.png"; Content = new ScrollView { Content = new StackLayout { Margin = new Thickness(20), Children = { new Label { Text = "Image Upload and Download", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }, imageToUpload, uploadButton, activityIndicator, downloadButton, downloadedImage } } }; }
public TextFileUploaderPageCS() { var uploadEditor = new Editor { HeightRequest = 100 }; var downloadEditor = new Editor { HeightRequest = 100, IsEnabled = false }; var activityIndicator = new ActivityIndicator(); var downloadButton = new Button { Text = "Download", IsEnabled = false }; downloadButton.Clicked += async(sender, e) => { if (!string.IsNullOrWhiteSpace(uploadedFilename)) { activityIndicator.IsRunning = true; var byteData = await AzureStorage.GetFileAsync(ContainerType.Text, uploadedFilename); var text = Encoding.UTF8.GetString(byteData); downloadEditor.Text = text; activityIndicator.IsRunning = false; } }; var uploadButton = new Button { Text = "Upload" }; uploadButton.Clicked += async(sender, e) => { if (!string.IsNullOrWhiteSpace(uploadEditor.Text)) { activityIndicator.IsRunning = true; var byteData = Encoding.UTF8.GetBytes(uploadEditor.Text); uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Text, new MemoryStream(byteData), ""); downloadButton.IsEnabled = true; activityIndicator.IsRunning = false; } }; Title = "Upload Text"; Icon = "csharp.png"; Content = new StackLayout { Margin = new Thickness(20), Children = { new Label { Text = "Text Upload and Download", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }, new Label { Text = "Enter text:" }, uploadEditor, uploadButton, activityIndicator, downloadButton, downloadEditor } }; }