← All changes
|
includes/Core/Integration/ZohoMail/FilesApiHelper.php
+1
-19
3.2.2
→
2.15.3
View file →
| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ZohoMail; |
| 9 | 9 | |
| 10 | -use BitCode\BitForm\Core\Util\FileHandler; | |
| 11 | 10 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * Provide functionality for Upload files |
| @@ -23,14 +22,13 @@ | ||
| 23 | 22 | { |
| 24 | 23 | $this->_payloadBoundary = wp_generate_password(24); |
| 25 | 24 | $this->_defaultHeader['Authorization'] = "Zoho-oauthtoken {$tokenDetails->access_token}"; |
| 26 | 25 | $this->_defaultHeader['Content-Type'] = 'application/octet-stream; boundary=' . $this->_payloadBoundary; |
| 27 | - $this->_basepath = FileHandler::getEntriesFileUploadDir($formID, $entryID) . DIRECTORY_SEPARATOR; | |
| 26 | + $this->_basepath = BITFORMS_UPLOAD_DIR . DIRECTORY_SEPARATOR . $formID . DIRECTORY_SEPARATOR . $entryID . DIRECTORY_SEPARATOR; | |
| 28 | 27 | } |
| 29 | 28 | |
| 30 | 29 | public function uploadFiles($files, $accountId, $dataCenter) |
| 31 | 30 | { |
| 32 | - $files = self::normalizeFileNames($files); | |
| 33 | 31 | $uploadFileEndpoint = "https://mail.zoho.{$dataCenter}/api/accounts/{$accountId}/messages/attachments"; |
| 34 | 32 | |
| 35 | 33 | $payload = ''; |
| 36 | 34 | |
| @@ -48,22 +46,6 @@ | ||
| 48 | 46 | $uploadResponse = HttpHelper::post($uploadFileEndpoint, $payload, $this->_defaultHeader); |
| 49 | 47 | |
| 50 | 48 | return $uploadResponse; |
| 51 | 49 | } |
| 52 | - } | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * Field values may arrive as public file URLs (see IntegrationHandler::handleFileUrl), | |
| 56 | - * so reduce each to the stored file name before resolving against the entry directory. | |
| 57 | - * | |
| 58 | - * @param mixed $files file name(s) or URL(s) | |
| 59 | - * | |
| 60 | - * @return mixed | |
| 61 | - */ | |
| 62 | - private static function normalizeFileNames($files) | |
| 63 | - { | |
| 64 | - if (is_array($files)) { | |
| 65 | - return array_map([__CLASS__, 'normalizeFileNames'], $files); | |
| 66 | - } | |
| 67 | - return is_string($files) ? basename(parse_url($files, PHP_URL_PATH) ?: $files) : $files; | |
| 68 | 50 | } |
| 69 | 51 | } |