eduardoarandah / medialibrary-dropzone-for-laravel-backpack

Adds the dropzone component to add multiple images via medialibrary backend
6 stars 2 forks source link

Items don't get uploaded #6

Open tabacitu opened 3 years ago

tabacitu commented 3 years ago

I haven't been able to successfully upload an item so far. I've followed the instructions in the README, created ProductPictureController.php to handle the uploads, with your default code (replaced MyModel with Product of course):

Screenshot 2020-08-14 at 12 04 42

But the code inside the method itself is pretty freakin' simple:

  public function store(Request $request, Product $model)
  {
    $media = $model->addMedia($request->file('file'))->toMediaCollection();
    return $media->getUrl();
  }

As far as I can tell, it fails at getting the URL (the second line).

So my question is:

Cheers!

eduardoarandah commented 3 years ago

So strange... looks like addMedia worked and then getUrl fails So I guess your model is correct.

Retrieving media docs:

https://docs.spatie.be/laravel-medialibrary/v8/basic-usage/retrieving-media/#main

Just after media is uploaded, in javascript, getPictures must be called:

https://github.com/eduardoarandah/medialibrary-dropzone-for-laravel-backpack/blob/master/src/resources/views/fields/medialibrary-dropzone.blade.php#L95

tabacitu commented 3 years ago

@pxpm, @promatik could you please help us out here? I'd really love to help @eduardoarandah finish up a first version of this package in the next few months, I think it'll be super-useful.

I think it's also a good opportunity for seeing how we can jump on a 3rd party add-on and help improve it, to the point where we can use it ourselves, add it to our add-ons page and tell Backpack devs to use it. Sort of an end-to-end help on developing Backpack add-ons, if you will 😀 It should help us hone how we build add-ons, which will be more and more important in v4.2 and v12.

Of course this doesn't take priority over Backpack 4.1 bugs, but I think it's something cool and constructive to work on, that would also greatly benefit the community. Let me know what you guys think about this, if you were able to install and use it and how you see it improved.