step-up-labs / firebase-storage-dotnet

C# library for Firebase Storage
MIT License
140 stars 35 forks source link

Multiple Images Upload #31

Closed osmanghaziurdu closed 4 years ago

osmanghaziurdu commented 4 years ago

I am Facing a Problem In Multiple Images Upload . I'm Using a plugin called XAM.PLUGIN.MEDIA to Get a Image File from my Phone Local Storage & Then Upload to Firebase Storage, But the Image Name Remains the Same . The First Image Automatically Deleted and New Image Uploads With the Same Name .

using Firebase.Storage; using Plugin.Media; using Plugin.Media.Abstractions; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms;

namespace App13 { // Learn more about making custom code visible in the Xamarin.Forms previewer // by visiting https://aka.ms/xamarinforms-previewer [DesignTimeVisible(true)] public partial class MainPage : ContentPage { MediaFile file; public MainPage() { InitializeComponent();

        imgBanner.Source = ImageSource.FromResource("XamarinFirebase.images.banner.png");
        imgChoosed.Source = ImageSource.FromResource("XamarinFirebase.images.default.jpg");
    }

    private async void BtnPick_Clicked(object sender, EventArgs e)
    {
        await CrossMedia.Current.Initialize();
        try
        {
            file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
            {
                PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
            });
            if (file == null)
                return;
            imgChoosed.Source = ImageSource.FromStream(() =>
            {
                var imageStram = file.GetStream();
                return imageStram;
            });
            await StoreImages(file.GetStream());
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
        }
    }

    private async void BtnStore_Clicked(object sender, EventArgs e)
    {
        await StoreImages(file.GetStream());
        await DisplayAlert("Hurrah!", "Your image has been successfuly Uploaded.", "OK");

    }

    public async Task<string> StoreImages(Stream imageStream)
    {
        var stroageImage = await new FirebaseStorage("")
            .Child("XamarinMonkeys")
            .Child("image.jpg")
            .PutAsync(imageStream);
        string imgurl = stroageImage;
        return imgurl;
    }
}

}

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing the issue due to inactivity. Feel free to re-open