← All changes
|
includes/Core/Integration/ZohoRecruit/FilesApiHelper.php
+17
-0
3.2.0
→
3.3.1
View file →
| @@ -50,8 +50,9 @@ | ||
| 50 | 50 | * @return array $uploadedFiles ID's of uploaded file in Zoho Recruit |
| 51 | 51 | */ |
| 52 | 52 | public function uploadFiles($files, $recordID, $zohoField) |
| 53 | 53 | { |
| 54 | + $files = self::normalizeFileNames($files); | |
| 54 | 55 | $uploadFileEndpoint = ''; |
| 55 | 56 | |
| 56 | 57 | if ('Candidate Photo' === $zohoField) { |
| 57 | 58 | $uploadFileEndpoint = "https://recruit.zoho.{$this->_dataCenter}/recruit/private/xml/{$this->_module}/uploadPhoto?Scope=recruitapi&type={$zohoField}&version=2&id={$recordID}"; |
| @@ -85,6 +86,22 @@ | ||
| 85 | 86 | return false; |
| 86 | 87 | } |
| 87 | 88 | $payload .= '--' . $this->_payloadBoundary . '--'; |
| 88 | 89 | return HttpHelper::post($uploadFileEndpoint, $payload, $this->_defaultHeader); |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Field values may arrive as public file URLs (see IntegrationHandler::handleFileUrl), | |
| 94 | + * so reduce each to the stored file name before resolving against the entry directory. | |
| 95 | + * | |
| 96 | + * @param mixed $files file name(s) or URL(s) | |
| 97 | + * | |
| 98 | + * @return mixed | |
| 99 | + */ | |
| 100 | + private static function normalizeFileNames($files) | |
| 101 | + { | |
| 102 | + if (is_array($files)) { | |
| 103 | + return array_map([__CLASS__, 'normalizeFileNames'], $files); | |
| 104 | + } | |
| 105 | + return is_string($files) ? basename(wp_parse_url($files, PHP_URL_PATH) ?: $files) : $files; | |
| 89 | 106 | } |
| 90 | 107 | } |