Laravel-Backpack / medialibrary-uploaders

MIT License
9 stars 3 forks source link

[Bug] How does `withUploads()` work? Does it? #10

Closed tabacitu closed 1 year ago

tabacitu commented 1 year ago

Bug report

What I did

Created a new Book model and CRUD. Then started adding fields to test withUploads() the way I would expect them to work, since no docs are provided:

        CRUD::field('cover_photo')->type('image')->withUploads();
        CRUD::field('free_chapters')->type('upload')->withUploads();
        CRUD::field('shipping_sheet')->type('upload_multiple')->withUploads();

What I expected to happen

Work when I submit the form.

What happened

No work when I submit the form: https://flareapp.io/share/omwRYvR5#F78

CleanShot 2023-03-07 at 15 16 44@2x
tabacitu commented 1 year ago

I don't know if this is broken, or I used it the wrong way... because it doesn't have any docs. So @pxpm let's please create some sort of docs for withUploads(), even if just in this thread. And if that was supposed to work... please check why it doesn't.

tabacitu commented 1 year ago

Ok so I figured out the above was because my upload_multiple attribute wasn't being cast to array in the model. Moving forward with the testing!

tabacitu commented 1 year ago

I was able to get all fields working 🎉 Well at least partially. I have the same definition as in my first post here. And I've uploaded the files! But I can't preview them:

CleanShot 2023-03-07 at 15 29 27@2x

And if I click on them, I get 404.

Where do files get stored by default? And why is that different than what the fields expect, if no prefix/path was specified?

tabacitu commented 1 year ago

Actually looks to me like they didn't get stored anywhere.

I mean... they're not in public soo... i think the upload didn't work. Which is odd.

tabacitu commented 1 year ago

Wait wait WAIT! They were uploaded, but in the ROOT, instead of in storage/app/public: CleanShot 2023-03-07 at 15 38 02@2x

This is a bug, right? It makes no sense to allow someone to upload to the root. I also notice it's uploaded as a new directory with the filename, then a file with a hashed name. That's... odd... right?

CleanShot 2023-03-07 at 15 40 17@2x