-
Notifications
You must be signed in to change notification settings - Fork 22
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
[Question] Path Prefixing #53
Comments
Hey, sure thing, Should be as simple as wrapping your Edit 2: Yea sorry you also have to So update $adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
'http://testing.b-cdn.net' # Optional
); to be $adapter = new PathPrefixedAdapter(
new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
'http://testing.b-cdn.net' # Optional
),
'prefix'
); (Disclaimer) I wrote it by hand so no idea if it works. It's got test coverage though Source: https://flysystem.thephpleague.com/docs/adapter/path-prefixing/ |
Funky, that is what I have; I believe. $adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
$config['pullzone_url'] ?? null
);
$adapter = new PathPrefixedAdapter($adapter, 'images/mails'); Which is what throws the exception when trying to generate the URL. Full example: Storage::extend('bunnycdn-mail', function (Application $app, array $config) {
$adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
$config['pullzone_url'] ?? null
);
$adapter = new PathPrefixedAdapter($adapter, 'images/mails');
return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$config);
}); |
Let me have a quick look now for ya |
Oohhh, this is where it gets funky. I am trying to store email images on Bunny, instead of locally. |
Huh.... Well. Because The quick & dirty: Best way I'm going to suggest is to extend the # /app/Providers/Support/PathPrefixedAdapter.php
<?php
namespace App\Providers\Support;
use League\Flysystem\Config;
class PathPrefixedAdapter extends \League\Flysystem\PathPrefixing\PathPrefixedAdapter
{
public function getUrl($path): string
{
return $this->publicUrl($path, new Config());
}
} Then use that The actual fix:
|
I'll open a quick PR for Laravel now |
Ah great! Thanks for the amazingly quick response! |
Hello!
How do you set-up the path prefixing?
I've attempted to set it up with Laravel, and it uploads the files as expected in the prefixed path, but upon URL retrieval it throws:
"This driver does not support retrieving URLs.",
Do you have an example with a prefixed path?
The text was updated successfully, but these errors were encountered: