putObject($input, $bucket, $uri); // Tentatively accept that this method succeeded. $result = true; // Should I download the file and compare its contents with my random data? if (static::$downloadAfter) { $downloadedData = $s3->getObject($bucket, $uri); $result = static::areStringsEqual($sourceData, $downloadedData); } // Should I delete the remotely stored file? if (static::$deleteRemote) { // Delete the remote file. Throws exception if it fails. $s3->deleteObject($bucket, $uri); } return $result; } private static function createXMLFile(int $size): string { $out = <<< XML XML; $chunks = floor(($size - 55) / 1024); for ($i = 1; $i <= $chunks; $i++) { $randomBlock = static::genRandomData(1024 - 63); $out .= <<< XML $i XML; } $out .= <<< XML XML; return $out; } private static function genRandomData(int $length): string { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890'; $maxLength = strlen($chars) - 1; $salt = ''; for ($i = 0; $i < $length; $i++) { $salt .= substr($chars, random_int(0, $maxLength), 1); } return $salt; } }