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

Suggestion #11

Open
jdson7 opened this issue May 6, 2020 · 0 comments
Open

Suggestion #11

jdson7 opened this issue May 6, 2020 · 0 comments

Comments

@jdson7
Copy link

jdson7 commented May 6, 2020

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);
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants