Giter Club home page Giter Club logo

flysystem-aws-s3-v2's Introduction

Flysystem Adapter for AWS S3 SDK v2

Author Build Status Coverage Status Quality Score Software License Packagist Version Total Downloads

Installation

composer require league/flysystem-aws-s3-v2

Usage

use Aws\S3\S3Client;
use League\Flysystem\AwsS3v2\AwsS3Adapter;
use League\Flysystem\Filesystem;

$client = S3Client::factory(array(
    'key'    => '[your key]',
    'secret' => '[your secret]',
    'region' => '[aws-region]',
));

$adapter = new AwsS3Adapter($client, 'bucket-name', 'optional-prefix');

$filesystem = new Filesystem($adapter);

flysystem-aws-s3-v2's People

Contributors

creocoder avatar frankdejonge avatar grahamcampbell avatar ifdattic avatar zaak 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flysystem-aws-s3-v2's Issues

Stream file from S3

I'm trying the same thing in a laravel app as this original issue thephpleague/flysystem#273 - downloading a file, ranging from 10M - 1G+, from S3. It appeared my app had to fully download the file from S3 before it would stream to the client, not seamlessly stream the file.

Is this still not possible?

Or is there a better way I should be handling this?

$s3Client = S3Client::factory([
    'key' => '<key>',
    'secret' => '<secret>',
]);
// Not sure if this is actually needed w/ Flysystem?
$s3Client->registerStreamWrapper();                                                    

$filesystem = new Filesystem(
    new AwsS3Adapter($s3Client, '<bucket>')
);

return \Response::stream(function() use ($filesystem, $file) {
    fpassthru($filesystem->readStream($file));
}, 200, $headers);

As a side note - if I utilize the recommended offered approach from AWS to download, it appears to work correctly. http://docs.aws.amazon.com/aws-sdk-php/guide/latest/feature-s3-stream-wrapper.html#downloading-data

$stream = fopen($file, 'r')
return \Response::stream(function() use ($stream) {              
    while (!feof($stream)) {                                     
        echo fread($stream, 1024);                               
    }                                                            
    fclose($stream);                                             
}, 200, $headers); 

$filesystem->delete('...') always returns false

Using AwsS3Adapter I'm trying following:

$filesystem->write('foo/bar.txt', 'abc');
$filesystem->delete('foo/bar.txt');

AwsS3Adapter::delete() always returns false, but file is removed properly.

$response received here looks like this:

array (size=3)
    'DeleteMarker' => boolean false
    'VersionId' => string '' (length=0)
    'RequestId' => string '25BE8BFBA63C5C91' (length=16)

Tested with AWS-SDK v2.7.17, also tried with latest master with the same result.

Laravel Custom File System Extending Storage Returns Null

Hi there,

I have the following code set up to create a custom file system.

<?php

namespace App\Providers;

use Storage;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v2\AwsS3Adapter;
use League\Flysystem\Filesystem;

class AwsS3v2ServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Storage::extend('s3', function($app, $config) {
          $client = S3Client::factory([
              'key'    => $config['key'],
              'secret' => $config['secret'],
              'region' => $config['region'],
              'base_url' => $config['endpoint'],
          ]);

          $adapter = new AwsS3Adapter($client, $config['bucket']);

          $filesystem = new Filesystem($adapter);
        });


    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

I am trying to run the following -

$url = Storage::disk('spaces')->temporaryUrl(
  'ea8dfb3d697884c2d8570407980b1b9f.memes.docx', Carbon\Carbon::now()->addMinutes(5)
);

But I get an array stating temporaryUrl cannot be ran on null?

Not sure what I have done wrong, any help with be great!
Thank you

Read and readStream returning local path

Hello, I am doing this to connect to S3:

$filesystem = $fh->connect();
$stream = $filesystem->readStream('path/to/file.txt');
$contents = stream_get_contents($stream);
fclose($stream);

var_dump($contents);

However it return a path like this -

string '/private/var/tmp/phpnkNhV1' (length=26)

This happens no matter if I use readStream or read. When I get the contents of the path, I get an error saying that the path doesn't exist.

License

Hi,

I'd like to know what is the license of the project and if it could be included in the source code.

Thanks!

Visibility for writeObject

Global visibility parameter is not passed to
protected function writeObject(array $options) on line 163 of AwsS3Adapter

I set the global parameter like this:
return new League\Flysystem\Filesystem($adapter, null, array('visibility' => 'public'));

Is it me or is it missing?

Filepath returned after fetching object points to non-existent file

This is an odd one and, to be honest, I'm not even sure if this is the right place for this but it seems the most relevant.

I am using this package with Laravel 5.0.

I have a command that handles files stores on s3. Using Laravel's FileSystem(FlySystem) with this package I obtain a file from s3:

$s3Disk->get($fileLocation)

The returned value of this method is a string filepath to private/var/temp/xxxxx, which is the location of the file contents obtained from s3.

This works as expected when my app is running synchronously and the command is executed when it is invoked, however when I use queued commands and instead execute these commands from a listener I get different behavior from FlySystem.

When run on a listener $s3Disk->get($fileLocation) still returns a filepath but the file does not exist.

In case you are not familiar with Laravel's commands/queues the code that is being executed in context to FlySystem (in the command) is identical -- it doesn't matter if it's synchronous or run by a listener after fetching it from a queue, it's all the same code in a handle() method in the command.

Can anyone provide any insight into why this might happen?

I have a hunch that it is caused by the context the application is running in (single process, synchronous request vs. listener where the app is a child process?) and somehow temporary files are being cleaned up immediately after creation but I really have no idea.

PathStyle => 'True' is ignored

When trying to use a PathStyle url, it seems like the option is ignored.

$options = [
        'PathStyle' => true,
];
$adapter = new AwsS3Adapter($client, $bucket, null, $options);

I always get calls to http://.host and not http://host/.

I create the client like so...

$client = S3Client::factory([
				                'base_url' => $Host,
				                'key'    => $AccessKey,
				                'secret' => $SecretKey,
				                'validation' => false,
				                'version' => '2006-03-01']);

Would love to get a tip on this.

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.