Skip to content

Suggestion #11

Description

@jdson7

I have a suggestion not to raise an exception when many files are passed and some of them do not exist, even though the parameter $checkObjectExist.

In the file src\S3ObjectsStreamZip.php

foreach ($objects as $object) {
	/*
	 * Added this IF to generate even if the current file doesn't exist
	 */
	if (file_exists($objectDir)) {
		$objectName = isset($object["name"]) ? $object["name"] : basename($object["path"]);

		$context = stream_context_create(array(
		  "s3" => array("seekable" => true)
		));

		$request = $this->s3Client->createPresignedRequest(
		  $this->s3Client->getCommand("GetObject", [
			"Key" => $object["path"],
			"Bucket" => $bucket,
		  ]),
		  "+1 day"
		);

		$tmpfile = tempnam(sys_get_temp_dir(), crc32(time()));

		$httpClient->request("GET", (string) $request->getUri(), array(
		  "synchronous"	=> true,
		  "sink" => fopen($tmpfile, "w+")
		));

		if ($stream = fopen($tmpfile, "r", false, $context)) {
		  $zip->addFileFromStream($objectName, $stream);
		}
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions