Skip to content

Suggestionย #11

Open
Open
@jdson7

Description

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);
		}
	}
}

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions