Coder Social home page Coder Social logo

1up-lab / oneupflysystembundle Goto Github PK

View Code? Open in Web Editor NEW
629.0 14.0 119.0 392 KB

A Flysystem integration for your Symfony projects.

License: MIT License

PHP 100.00%
flysystem symfony filesystem php gaufrette aws-s3 dropbox rackspace gridfs replicate

oneupflysystembundle's Introduction

OneupFlysystemBundle

Build Status Total Downloads

Now 4.x available with Flysystem V2 & V3 support!

The OneupFlysystemBundle provides a Flysystem integration for your Symfony projects. Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one. Currently you can configure the following adapters to use in your Symfony project.

Documentation

The entry point of the documentation can be found in the file doc/index.md

Read the documentation for the latest release

Flysystem 1.x

If you're looking for Flysystem 1.x support, check out the 3.x-branch of this bundle.

License

This bundle is under the MIT license. See the complete license in the bundle:

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.

When reporting a bug, it may be a good idea to reproduce it in a basic project built using the symfony/website-skeleton to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.

oneupflysystembundle's People

Contributors

andreas-glaser avatar bytehead avatar chosroes avatar chris53897 avatar davidfuhr avatar derrabus avatar guillaume-ro-fr avatar hshn avatar ikimoo avatar k-phoen avatar kix avatar kozzi11 avatar mbabker avatar meyerbaptiste avatar mihaileu avatar nicojust avatar nyholm avatar phoenixgao avatar piotrantosik avatar rdrenth avatar ricbra avatar samnela avatar sheeep avatar simoheinonen avatar tacman avatar teohhanhui avatar vojtabiberle avatar vvh-empora avatar yaffol avatar yellow1912 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oneupflysystembundle's Issues

Confusing documentation for plugins

The docs for creating a plugin state that you should tag your service with oneup_flysystem.filesystem_plugin yet it seems its actually looking for $plugins = $container->findTaggedServiceIds('oneup_flysystem.plugin');

Flysystem credentials problem with S3 adapter

I have problem in working Flysystem with Amazon S3 adapter.
I configured probably correct service and bundle but I can see credentials problem.
Here is the full error message:

Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. ([curl] 52: Empty reply from server [url] http://169.254.169.254/latest/meta-data/iam/security-credentials/)

I'm using latest version of aws-sdk-php

"aws/aws-sdk-php": "2.7.*@dev"

My service configuration

XXX is my key, ZZZ is secret.

services:
    flysystem.s3_client:
        class: Aws\S3\S3Client
        factory_class: Aws\S3\S3Client
        factory_method: factory
        arguments:
            - ["XXX", "ZZZ"]

My adapter & filesystem configuration

oneup_flysystem:
    adapters:
        my.flysystem_adapter:
            awss3:
                client: flysystem.s3_client
                bucket: myuniquebucketname
                prefix: ~
    filesystems:
        photos:
            adapter: my.flysystem_adapter

PHP

When I try list elements in my bucket I received error with credentials.

$filesystem = $this->get('oneup_flysystem.photos_filesystem');
var_dump( $filesystem->listContents() );

I don't know what's wrong, so If anybody knows that, please help me :)

Replaced integerNode() by scalarNode()

When installing the bundle, two runtimeException showing a Fatal error is displayed:

  • Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\NodeBuilder::integerNode() in /var/www/lafourchette-core/vendor/oneup/flysystem-bundle/Oneup/FlysystemBundle/DependencyInjection/Factory/Adapter/FtpFactory.php on line 33

Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\NodeBuilder::integerNode() in /var/www/lafourchette-core/vendor/oneup/flysystem-bundle/Oneup/FlysystemBundle/DependencyInjection/Factory/Adapter/SftpFactory.php on line 33

Replacing integerNode() by scalarNode() fixes this error.

question on install

i ran composer and saw

  - Removing league/flysystem (1.0.3)
  - Installing league/flysystem (0.5.12)
    Downloading: 100%

  - Removing oneup/flysystem-bundle (dev-master)
  - Installing oneup/flysystem-bundle (v0.5.0)
    Downloading: 100%

wonder if you know why flysystem went back to 0.5.12

Local adapter: changing directory via compiler pass

Hi,

I need to change the directory value at runtime based on some infomation store in session. I thougth a compiler pass wuold do the job but it doesn't work.

oneup_flysystem:
adapters:
my_adapter:
local:
directory: 'path_to_be_changed'

Inside a compiler pass:
$container->setParameter('oneup_flysystem.adapters.my_adapter.local.directory', 'my_dynamic_path');

What's the way to achieve that?

Broken WebDav

When I configure a webdav adapter, I always get the following error:
OutOfBoundsException in Definition.php line 341:
The index "1" is not in the range [0, 0].

I found the cause:
in oneup/flysystem-bundle/Resources/config/adapters.xml the service oneup_flysystem.adapter.webdav is configured only to have one argument.

But in oneup/flysystem-bundle/DependencyInjection/Factory/Adapter/WebDavFactory.php
the create method tries to replace two arguments.

I have a local workaround in the services.yml of a bundle loaded afer the OneupFlysystemBundle and added the second argument:

services:
oneup_flysystem.adapter.webdav:
class: League\Flysystem\WebDAV\WebDAVAdapter
public: false
arguments: ['', '']

Document new dependencies.

If you want to use caches or any other adapter than the local one, you will need to install special dependencies. We have to thoroughly document these.

Setting permissions of Local adapter

Flysystem Local adapter constructor accepts $permissions argument:

public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::DISALLOW_LINKS, array $permissions = [])

Is there a way to set permissions in OneupFlysystemBundle ?

Tag a release

Could you tag a release? That way we all can require a non-moving target instead of dev-master :)

Error with AWSS3 and VichUploaderBundle

Hi,

I'm trying to use this bundle with the AWSS3 (using Flysistem). When I try to upload files, I get this error:

Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. ([curl] 28: Connection timed out after 5000 milliseconds [url] http://169.254.169.254/latest/meta-data/iam/security-credentials/)
// config.yml
oneup_flysystem:
    adapters:
        jp.flysystem_adapter:
            awss3:
                client: jp.s3_client
                bucket: jpuploads
                prefix: ~
    filesystems:
        image_fs:
            adapter:    jp.flysystem_adapter
            mount:      image_fs
// config.yml
vich_uploader:
    db_driver: orm

    flysystem: true
    storage: vich_uploader.storage.flysystem

    mappings:
        profile_picture:
            #uri_prefix: web
            upload_destination: image_fs
            namer:              vich_uploader.namer_uniqid
            delete_on_remove:   true
        advertisments:
            upload_destination: image_fs
            namer:              vich_uploader.namer_uniqid
            delete_on_remove:   true
        post_image:
            upload_destination: image_fs
            namer:              vich_uploader.namer_uniqid
            delete_on_remove:   true
// services.yml
    jp.s3_client:
            class: Aws\S3\S3Client
            factory_class: Aws\S3\S3Client
            factory_method: factory
            arguments:
                - ["KEY", "SECRET"]

I'm testing this on my development machine, which is unfortunately rather slow. But I don't know if this error is because of the actual timeout (so that the connecting part took too long), or if there's an error in my configuration.

Thanks in advance

Symfony configuration issue

Great bundle as first. I had to create factory wrapper class in order to go around symfony config file issue. Basically S3Client::factory requires config array as follows:

array(
    'key' => 'aws-key', 
    'secret' => 'aws-secret'
)

How do you configure this as a service in the container?

From bundle docs I can see this setup:

acme.s3_client:
        class: Aws\S3\S3Client
        factory_class: Aws\S3\S3Client
        factory_method: factory
        arguments:
            - ["s3-key", "s3-secret"]

But this does not work as this will create array as following:

array(
    '0' => 'aws-key', 
    '1' => 'aws-secret'
)

Is this error in docs, recent change in aws-php library or am I just missing something?

Configuring Rackspace adapter throws OutOfBoundsException

Hi,

After following the guide for configuring a Rackspace adapter, I'm presented with an OutOfBoundsException:

[Symfony\Component\DependencyInjection\Exception\OutOfBoundsException]
  The index "1" is not in the range [0, 0].

The way I've configured everything is as follows:

services.yml

services:
  my_rackspace_client:
    class: OpenCloud\Rackspace
    arguments:
     - "https://lon.identity.api.rackspacecloud.com/v2.0/"
     - username: "xxx"
       password: "xxx"

config.yml

oneup_flysystem:
  adapters:
    my_rackspace_adapter:
      rackspace:
        container: my_rackspace_client

  filesystems:
    my_rackspace_filesystem:
      adapter: my_rackspace_adapter
      mount: my_rackspace_filesystem

Any clues as to what might be causing this?

A more flexible way to attach plugins to filesytem

Say if I have pluginA that I want to attach to 3 (out of n) filesystems, I have to create 3 services separately. Maybe I'm mistaken but it should be possible to re-use the same plugin service for any number of filesystem.

My proposal is rather simple: allow passing the filesystem ids as a string (comma separated)

<service id="assetic.filesystem.plugin.awss3_url" class="%assetic.filesystem.plugin.awss3_url.class%">
            <tag name="oneup_flysystem.plugin" filesystem="s3,local,remote" />
        </service>

Then in the compiler pass we can easily explode the string then loop through the array.

What do you think? I can implement it and send a PR, it's quite easy.

Class 'League\Flysystem\Cached\CachedAdapter' not found

PHP Fatal error: Class 'League\Flysystem\Cached\CachedAdapter' not found in ../app/cache/dev/appDevDebugProjectContainer.php

config.xml
oneup_flysystem:

filesystems:
    acme:
        adapter: my_adapter
        cache: my_cache
        alias: ~
        mount: ~
cache:
    my_cache:
        memory: ~
adapters:
    my_adapter:
        local:
            directory: %kernel.root_dir%/../push_response

I have no idea, why the cache file not include the adapter class in current latest version. But pervious version it's works.

Error retrieving credentials from the instance profile metadata server

Hi,
I get a similar issue as the one described here in #29
I do have the correct service definition though:

birdfeed.s3.client:
    class: Aws\S3\S3Client
    factory_class: Aws\S3\S3Client
    factory_method: factory
    arguments:
      -
        version: '2006-03-01'
        region: 'us-east-1'
        key: "myKey"
        secret: "mySecret"

Is there something I am doing wrong ?

Working with big files 100 MO - Error: Allowed memory size

well i m try to work with files > 100 Mo

i have this error :

FatalErrorException: Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 106839070 bytes) in /var/www/html/demo-Symfony2-Flysystem/Symfony/vendor/league/flysystem/src/Adapter/Local.php line 165

how fix that please ?

Installation issue -

Hello evrybody, well i relly like flystem, but i can't use it with my symfony program can help me please.

to install i do that :

so on frech symfony2 install :
1> in composer.json i add this :

{
    "require": {
        "oneup/flysystem-bundle": "@stable"
    }
}

after that i update my composer with command :
php composer.phar update

After that i add line on my config files :
in appkernel.php

   new Oneup\FlysystemBundle\OneupFlysystemBundle(),

and in config.yml

oneup_flysystem:
    adapters:
        my_adapter:
            local:
                directory: %kernel.root_dir%/../uploads   

and now on y controler i want show a directory :

<?php

namespace Demo\P1RetourDemo\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class DefaultController extends Controller
{
    /**
     * @Route("/")
     * @Template()
     */
    public function indexAction()
    {
        $name = 'test Page de demmarage';

        $plugins = $container->findTaggedServiceIds('oneup_flysystem.plugin');

        return array('name' => $name);
    }



    /**
     * @Route("/FileRetourPs/{name}")
     * @Template()
     */
    public function fileRetourPsAction($name)
    {
        return array('name' => $name);
    }
}

and so when i lunch my page i have this error :

Whoops, looks like something went wrong.
1/1 ContextErrorException: Notice: Undefined variable: container in /var/www/demo01/Symfony/src/Demo/P1RetourDemoBundle/Controller/DefaultController.php line 20

so what is wrong please :

You have requested a non-existent service "oneup_flysystem.my_filesystem"

I've tried setting up the file system as per the instructions, for use with AWS S3 buckets, however I'm being told that the service does not exist.

Using Xdebug I can trace that the compiler pass runs & seems to have the the service available during the cache clearing phase, but using container:debug, or attaempting to use the services in the wild report that it doesn't exists.

Here's my config…

# services.yml
services:
    # ...
    acme.s3_client:
        class: Aws\S3\S3Client
        factory_class: Aws\S3\S3Client
        factory_method: factory
        arguments:
            -
                key: %s3_user%
                secret: %s3_secret%
# config.yml
oneup_flysystem:
    adapters:
        acme.flysystem_adapter:
            awss3v2:
                client: acme.s3_client
                bucket: %s3_bucket%
                prefix: ~
    filesystems:
        acme:
            adapter: acme.flysystem_adapter
            cache: ~
            alias: acme.flysystem
            mount: ~

Can anyone help me work out why the service is not available?

Thanks in advance

Cannot mount a fileSystem : No filesystem mounted with prefix

here is my config (which is really simple),

oneup_flysystem:
    adapters:
        my_adapter:
            local:
                directory: %kernel.root_dir%/../../web/uploads
    filesystems:
        my_filesystem:
            adapter: my_adapter

and how I get my fileSytem :

$this->mountManager->getFilesystem(“my_filesystem”);

But when i tried to get my fileSystem it give me this error :
No filesystem mounted with prefix my_filesystem

Actually i'am using v0.4.1
thank you for your help

Rearrange the options array

Right now we are configuring the system like this:

filesystems:
        s3_lib:
            adapter: s3_lib
            visibility: public
            cache: local

Then in the DI Extension we have to check manually:

$options = [];
        if (array_key_exists('visibility', $config)) {
            $options['visibility'] = $config['visibility'];
        }

This will get troublesome later when new options are available etc. I suggest we change it to this:

filesystems:
        s3_lib:
            adapter: s3_lib
            options:
                visibility: public
            cache: local

We can then easily use $config['options'] array in our DI Extension.

Global plugin attachment

See #42

oneup_flysystem:
    plugins:
        - global_plugin
    filesystems:
        my_filesystem:
            plugins:
                - local_plugin

Whereas global_plugin is available for every configured filesystem and local_plugin only for my_filesystem.

Fatal Error: CachedAdapter not found

Hi,

I updated the version and I get this error: PHP Fatal error: Class 'League\Flysystem\Cached\CachedAdapter' not found

I have this versions in composer.json:

"oneup/flysystem-bundle"                            : "1.1.0",
"league/flysystem-aws-s3-v2"                        : "~1.0",

Where is the problem ?

Thanks

Simplify the process of adding custom adapter

Right now it seems like it's not easy to add new adapter because the AdapterFactories are defined in this Bundle's DI folder. It should be easier to define a new custom adapter else where and simply refer to it in the config.

[DX] Proposal: Consolidate filesystems, adapters and cache

Currently, configuration looks like this:

oneup_flysystem:
    cache:
        my_cache:
            noop: ~

    adapters:
        my_adapter:
            local:
                directory: %kernel.root_dir%/cache

    filesystems:
        my_filesystem:
            adapter: my_adapter
            cache: my_cache

I think splitting adapters and cache into its own sections might make sense for some edge-case re-usability, but it makes the bundle harder to understand for new people. Also, by leveraging parameters, we still have a lot of re-usability with my proposal.

Here's what I propose:

oneup_flysystem:
    filesystems:
        my_filesystem:
            adapter:
                local:
                    directory: %kernel.root_dir%/cache
            cache:
                noop: ~

Thoughts? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.