From 3d833fb6c15b454d378642076e5c3b368b198ebd Mon Sep 17 00:00:00 2001 From: Jeffery Antoniuk Date: Thu, 16 Jan 2025 13:53:41 -0700 Subject: [PATCH] Handle zero length media files; address https://github.com/cwrc/leaf-isle-bagger/issues/26 --- src/Plugin/AddMedia.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Plugin/AddMedia.php b/src/Plugin/AddMedia.php index 39c2b89..4297261 100644 --- a/src/Plugin/AddMedia.php +++ b/src/Plugin/AddMedia.php @@ -114,9 +114,9 @@ public function execute(Bag $bag, $bag_temp_dir, $nid, $node_json, $token = NULL 'verify' => $this->settings['verify_ca'] ]); $file_body = $file_response->getBody(); - while (!$file_body->eof()) { + do { file_put_contents($temp_file_path, $file_body->read(2048), FILE_APPEND); - } + } while (!$file_body->eof()); $bag->addFile($temp_file_path, $this->settings['media_file_directories'] . basename($temp_file_path)); } }