Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request #2

Closed
hpoit opened this issue Mar 1, 2021 · 16 comments
Closed

Feature request #2

hpoit opened this issue Mar 1, 2021 · 16 comments

Comments

@hpoit
Copy link

hpoit commented Mar 1, 2021

Hi Peter,

Nice work you did with this app. Could I ask you to demo how to write to Storage while linking to Store, from the phone's gallery, and then read from Store, photoURL included?

Thanks, Hpoit

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 1, 2021

Hi @hpoit that's already done, check my article how to use Firebase Storage in flutter

@hpoit
Copy link
Author

hpoit commented Mar 1, 2021 via email

@hpoit
Copy link
Author

hpoit commented Mar 1, 2021 via email

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 1, 2021

The image picker also only selects an image. The save image button does not write to Store or Storage.

On Sun, Feb 28, 2021 at 9:50 PM Kevin Liu @.> wrote: Hi Peter, I've read your tutorial, but the app does not do what the tutorial said it does. The app does not save to Storage or Store. The image(s) that the get button fetches are not from Firebase, but from heap memory. I had Store and Storage emptied out before clicking the get button, and the images still appeared. On Sun, Feb 28, 2021 at 9:42 PM Peter Haddad @.> wrote: > Hi @hpoit https://github.com/hpoit that's already done, check my > article how to use Firebase Storage in flutter > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <#2 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AA4KA7CCCHYFC2T7GLEO5VDTBLPI3ANCNFSM4YLUBDVQ > . >

Did you enable read and write on your firestore and storage rules? I will try and check it tomorrow what firebase storage/firestore version are you using?

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 1, 2021

Btw the article first stores some images that are under the assets folder to storage, then in the second section I write about the image picker storing and retrieving image from firestore.

@hpoit
Copy link
Author

hpoit commented Mar 1, 2021 via email

@hpoit
Copy link
Author

hpoit commented Mar 1, 2021

So I just tried 'Save image' after 'Pick image'. The image is not saved to Storage or Store. I will try tomorrow again at a different location, this might sound crazy, but I think it might have to do with internet speed. The save image button on main does not save either.

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 1, 2021

Hi, I just tried at first it didn't work I entered my firebase console and updated the rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {

    // This rule allows anyone on the internet to view, edit, and delete
    // all data in your Firestore database. It is useful for getting
    // started, but it is configured to expire after 30 days because it
    // leaves your app open to attackers. At that time, all client
    // requests to your Firestore database will be denied.
    //
    // Make sure to write security rules for your app before that time, or else
    // your app will lose access to your Firestore database
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2023, 12, 28);
    }
  }
}

above rules are just for testing.

image

image

image

image

Working normally, I have added progress indicator for the save image from imagepicker and commited to the repository, so you can take latest.

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 3, 2021

I feel like it worked with you, so gonna close this for now, feel free to reply in case it didn't work

@PeterHdd PeterHdd closed this as completed Mar 3, 2021
@andesappal
Copy link

Hi Peter,

Nice work you did with this app. Could I ask you to demo how to write to Storage while linking to Store, from the phone's gallery, and then read from Store, photoURL included?

Thanks, Hpoit

Hi Peter! I am sorry for the bad timing. So I tested your app again with your changes, thanks. My original request is to have the app, on Second Page, Save Image to Storage and Store. Would you help me with that? Right now, Save Image on Second Page only saves to Storage, not Store. Thank you Peter.

@andesappal
Copy link

Also, do you know how to image pick multiple images from the phone's gallery, then save each to Storage and Store?

@andesappal
Copy link

I have an app which uses an infinite list with Felix's Bloc pattern, and now I am trying to fit your code into my existing app.

@andesappal
Copy link

I am building an e-reader where the owner of the app would like to upload images, and then have the final users read the uploaded images. All images though have a text description below each image.

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 3, 2021

Hi Peter,
Nice work you did with this app. Could I ask you to demo how to write to Storage while linking to Store, from the phone's gallery, and then read from Store, photoURL included?
Thanks, Hpoit

Hi Peter! I am sorry for the bad timing. So I tested your app again with your changes, thanks. My original request is to have the app, on Second Page, Save Image to Storage and Store. Would you help me with that? Right now, Save Image on Second Page only saves to Storage, not Store. Thank you Peter.

Regarding this, you can check the main.dart file, it's actually pretty simple try and implement it on your own. Basically you need to do something like this:

                          .ref()
                          .child("images/$imageName")
                          .putFile(file)
                          .onComplete;
                      if (snapshot.error == null) {
                        final String downloadUrl =
                            await snapshot.ref.getDownloadURL();
                        await FirebaseFirestore.instance
                            .collection("images")
                            .add({"url": downloadUrl, "name": imageName});

You can only save the url in firestore which you can retrieve to show the image to the user. The add() method will write the data to firestore

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 3, 2021

Also, do you know how to image pick multiple images from the phone's gallery, then save each to Storage and Store?

For multiselect in gallery, I don't think the image picker works for that, check this plugin:
https://pub.dev/packages/multi_image_picker

@PeterHdd
Copy link
Owner

PeterHdd commented Mar 3, 2021

I am building an e-reader where the owner of the app would like to upload images, and then have the final users read the uploaded images. All images though have a text description below each image.

That's cool, using the code in the previous comment you can get the url, and add a description to each image which will be saved under a document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants