Code Monkey home page Code Monkey logo

s3-bucket-stream-zip-php's Introduction

S3BucketStreamZip

Build Status Scrutinizer Code Quality Code Coverage

Overview

This library lets you efficiently stream the contents of an S3 bucket/folder as a zip file to the client.

Installation

Installation is done via composer by adding the a dependency on jmathai/s3-bucket-stream-zip-php.

composer require jmathai/s3-bucket-stream-zip-php
composer install

Usage

// taken from examples/simple.php
// since large buckets may take lots of time we remove any time limits
set_time_limit(0);
require sprintf('%s/../vendor/autoload.php', __DIR__);

use JMathai\S3BucketStreamZip\S3BucketStreamZip;
use JMathai\S3BucketStreamZip\Exception\InvalidParameterException;

$stream = new S3BucketStreamZip(
            // $auth
            array(
              'key'     => '*********',   // required
              'secret'  => '*********'    // required
            ),
            // $params
            array(
              'Bucket'  => 'bucketname',  // required
              'Prefix'  => 'subfolder/'   // optional (path to folder to stream)
            )
          );

$stream->send('name-of-zipfile-to-send.zip');

Authors

Dependencies

s3-bucket-stream-zip-php's People

Contributors

jmathai 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

Watchers

 avatar  avatar  avatar  avatar

s3-bucket-stream-zip-php's Issues

Files inside the zip file have 0kb size

I just tested the library but is not working for me.

It downloaded a file called "name-of-zipfile-to-send.zip", it contains 2 files, but files are 0Kb size.

None of the files have data... any idea?

Note: My Bucket contains 2 files

Unable to composer install the package

Hi,
I am unable to composer install this because the package version of "aws/aws-sdk-php" is 2.8 and I already have 3.0.
Could you please update the package version here .

Thanks,
Pallavi

accessing 500+ files from s3 not possible

@jmathai I am using your script for stream zip and provide download file to the end user. It works fine for 30 or more files but when it comes to large bunch of files to download it give error message

This site can’t be reached
screen shot 2016-09-08 at 5 13 57 pm

Looks like fetching large number of files from S3 is not possible with the script. Please advise.

Want to run multiple zip download from for loop but closes tab after 1st zip download starts

How to download multiple zips from for-loop call
below code closes the browser tab 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>";
}
}

curl_setopt(): supplied argument is not a valid File-Handle resource ^2.0

here is my code:

$params = [
                "key" => "myKey",
                "secret" => "mySecret",
                "region" => "ap-southeast-1",
                "bucket" => "myBuket",
                "prefix" => "571/low/"
            ];
$stream = new S3BucketStreamZip($params);
$stream->send('name-of-zipfile-to-send.zip');
I'm sure all params is valid as I had upload successfully to my bucket, but I have no idea why I got this error, maybe something wrong for me related with this code (/jmathai/s3-bucket-stream-zip-php/src/S3BucketStreamZip.php):
$fp = tmpfile();
$ch = curl_init($signedUrl);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FILE, $fp);  // <---- 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
 curl_close($ch);

Thanks,
quoc

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.