Skip to content
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

Use AWS SDK for PHP v3 #3

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Use AWS SDK for PHP v3 #3

wants to merge 29 commits into from

Conversation

limenet
Copy link

@limenet limenet commented Oct 1, 2016

Thanks a lot for this class, exactly what I was looking for. However, since I needed to use v3 of the AWS SDK for PHP (due to Laravel and bucket location), I forked it and made a few changes.


This PR updates the library to use the v3 of the SDK, which is required to access S3 buckets which only support modern/more recent ciphers for encryption -- and it makes it compatible to use with e.g. Laravel 5.2.

The following changes were made:

  • Use AWS SDK for PHP v3
  • Use StyleCI to have a unified code style
  • changed the constructor to make it compatible with v3
  • include the non-prefix part of the filename in the ZIP which essentially allows for multiple folders in the archive

Thus, this probably warrants a major release according to semver as there are breaking changes.

Taken from the examples/simple.php, the new constructor looks like this:

$stream = new S3BucketStreamZip([
    'key'    => 'your-key-goes-here',
    'secret' => 'your-secret-goes-here',
    'bucket' => 'the-name-of-your-bucket',
    'region' => 'the-region-of-your-bucket',
    'prefix' => 'prefix-of-the-files-to-zip',
]);

I'm using these changes in a production environment with no issues so far. Let me know if you want me to make any changes!

@limenet
Copy link
Author

limenet commented Oct 1, 2016

I just realized the AWS PHP SDK v3 requires PHP >= 5.5. Considerin 7.0 is out now and 5.4 was EOL more than one year ago (even 5.5 is EOL), I think it's safe to drop support for these old versions.

@tomschlick
Copy link

Possible to get this merged soon? Could really use it on a project and as @limenet mentioned even PHP 5.5 is officially EOL.

A new tag of 2.0 could keep the old versions working without issue.

@limenet
Copy link
Author

limenet commented Mar 2, 2017

@tomschlick since I'm using this PR in production and haven't heard anything from @jmathai I decided to publish my fork as a standalone package. This, of course, comes with its own risks, however you're welcome to use limenet/s3-bucket-stream-zip-php in your project.
Only caveat: it's PHP 7.0+ only. Reason being I'm no longer using PHP 5.x and I don't want to publish a package I haven't tested on a version I'm not using.

@tomschlick
Copy link

@limenet thanks! I'll probably do just that. I'm using 7.1 so thats not an issue.

@ghostrocket
Copy link

can we get this merged?

@jmathai
Copy link
Owner

jmathai commented Apr 25, 2017

Sorry for the delay in replying here. It's been a while since I've worked with composer. Here's what I did and I think it should be sufficient but it would be great if someone can test (I am unable at the moment).

I created v1.0 (current master) and v2.0 (pulled this pr) branches. I also created and pushed the respective v1.0 and v2.0 tags. I believe that's all composer needs. If that's working for you to install v2.0 using composer then I'll go ahead and merge this into master and update the docs.

@DeepGandhi1602
Copy link

How to download multiple zips from for-loop call
below code closes the window when 1st zip download starts so that remaining loops cant work

i.e.
$RowImagesData = array() // in which multiple references are added.
$obj =& get_instance();
$obj->load->library('s3_stream');
$obj->load->library('aws_sdk');
$s3_dir= 'images/';
$bucketname= 'XYZ';

foreach ($RowImagesData as $RIKey => $RIValue)
{
$OrderId = $RIValue['reference']
$path = $s3_dir. $OrderId;
$files = $obj->aws_sdk->listObjects(array('Bucket' => $bucketname, 'MaxKeys' => 1000, 'Prefix' => $path))->getPath('Contents');
if(count($files) > 0)
{
$obj->s3_stream->download($bucketname,$path,$orderid);
}
else
{
echo "<script type='text/javascript'>alert('Order - $orderid does not exist');</script>";
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants