Closed marsderp closed 7 years ago
Hi, my apologies for this breaking change. We try to avoid this kind of trouble.
I'll try to look at this very soon.
pinging @nicolasbeauvais for any ideas how this might have been caused.
@marsd in the config file laravel-medialibrary.php
what did you specify in the custom_url_generator_class
key?
Currently null, was not changed previously.
'custom_url_generator_class' => null,
'custom_path_generator_class' => null,
I have the same issue after some debugging i have found the problem in FileManipulator.php line 138 ,it is trying to getPath and s3UrlGenerator doesn't have getPath method
@marsd you do not have custom URL generators but you are using s3 and it`s generator doesn't have a path
A fix has been made by @nicolasbeauvais in the master branch. Could you require dev-master
of this package in your composer.json
and let us know if your issue is resolved?
Experiencing the same issue here. Can confirm it is resolved in dev-master
.
Had the same issue. It was fixed by pulling the dev-master branch.
Fix has been tagged as v4.9.2
.
Reopen this issue if you're still having problems after upgrading to that version.
I'm having same problem with v4.9.2
:(
[2016-10-12 14:52:06] production.CRITICAL: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Spatie\MediaLibrary\UrlGenerator\S3UrlGenerator::getPath() in /vendor/spatie/laravel-medialibrary/src/Media.php:86
Stack trace:
#0 /vendor/spatie/laravel-medialibrary/src/ImageGenerators/BaseGenerator.php(21): Spatie\MediaLibrary\Media->getPath()
#1 /vendor/spatie/laravel-medialibrary/src/FileManipulator.php(138): Spatie\MediaLibrary\ImageGenerators\BaseGenerator->canConvert(Object(Spatie\MediaLibrary\Media))
#2 /vendor/spatie/laravel-medialibrary/src/FileManipulator.php(44): Spatie\MediaLibrary\FileManipulator->determineImageGenerator(Object(Spatie\MediaLibrary\Media))
#3 /vendor/spatie/laravel-medialibrary/src/FileManipulator.php(25): Spatie\MediaLibrary\FileManipulator->performConversions(Object(Spatie\MediaLibrary\Conversion\ConversionCollection), Object(Spatie\MediaLibrary\Media))
#4 /vendor/spatie/laravel-medialibrary/src/Filesystem.php(42): Spatie\MediaLibrary\FileManipulator->createDerivedFiles(Object(Spatie\MediaLibrary\Media))
#5 /vendor/spatie/laravel-medialibrary/src/FileAdder/FileAdder.php(328): Spatie\MediaLibrary\Filesystem->add('/tmp/media-libr...', Object(Spatie\MediaLibrary\Media), '163930_new_Y4Zi...')
#6 /vendor/spatie/laravel-medialibrary/src/FileAdder/FileAdder.php(251): Spatie\MediaLibrary\FileAdder\FileAdder->toCollectionOnDisk('default', '')
#7 /app/Jobs/ConvertOldSiteItemsJob.php(59): Spatie\MediaLibrary\FileAdder\FileAdder->toMediaLibrary()
#8 [internal function]: App\Jobs\ConvertOldSiteItemsJob->handle()
My code:
foreach ($this->images as $image) {
if ($image->url != '') {
$this->model->addMediaFromUrl($image->url)->toMediaLibrary();
}
}
@andaril take a look at this issue for a possible solution.
@freekmurze Yep, I found these issues later, but thanks. And I think this PR #329 is the solution. May be I must do pr with correct CS? 21 day is too long to wait response 😕
Closed the old PR, create a new PR to fix this
I'm still having this issue on v5:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to undefined method Spatie\MediaLibrary\UrlGenerator\S3UrlGenerator::getPath()
Exception trace:
() at /vendor/spatie/laravel-medialibrary/src/Media.php:81
Spatie\MediaLibrary\Media->getPath() at /vendor/spatie/laravel-medialibrary/src/ImageGenerators/BaseGenerator.php:24
Spatie\MediaLibrary\ImageGenerators\BaseGenerator->canConvert() at /vendor/spatie/laravel-medialibrary/src/FileManipulator.php:120
Actually tried out in a blank new Laravel 5.4 project.
// composer.json
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"spatie/laravel-medialibrary": "^5.0"
},
<?php
// User.php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
class User extends Authenticatable implements HasMedia
{
use Notifiable, HasMediaTrait;
// filesystem.php
'media' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
// tinker
Psy Shell v0.8.1 (PHP 7.0.8 — cli) by Justin Hileman
>>> use App\User
=> null
>>> use Faker\Factory
=> null
>>> $faker = Factory::create()
=> Faker\Generator {#678}
>>> User::first()->addMediaFromUrl($faker->imageUrl())->toMediaLibrary()
PHP error: Call to undefined method Spatie\MediaLibrary\UrlGenerator\S3UrlGenerator::getPath() in /Users/balazssebesteny/Sites/medialibrary-test/vendor/spatie/laravel-medialibrary/src/Media.php on line 81
PS: Create new ticket #534
After upgrading this package, the error now occurs when I upload from file to S3. None of my upload code was modified between the upgrade.
Current solution is to specify in composer
"spatie/laravel-medialibrary": "^4.8.4"
Here is a snippet of what my code is doing: