diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index ce9b27c3..aa83c129 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -85,26 +85,32 @@ class VidalApiController extends BaseController tpa_claim_push_log($claimId, "VIDAL - Claim Push | Received signed URL & fileId. fileId: $fileId"); - // Step 2: Upload file to signed URL using PUT (Azure Blob) - $fileSize = filesize($filePath); - $fileContent = fopen($filePath, 'r'); + + + // Step 2: Upload file to signed URL (real multipart — cURL adds boundary) + $mime = function_exists('mime_content_type') + ? (mime_content_type($filePath) ?: 'application/pdf') + : 'application/pdf'; + + $cfile = new \CURLFile($filePath, $mime, $filename); $ch2 = curl_init($signedUrl); - curl_setopt($ch2, CURLOPT_PUT, true); - curl_setopt($ch2, CURLOPT_INFILE, $fileContent); - curl_setopt($ch2, CURLOPT_INFILESIZE, $fileSize); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch2, CURLOPT_HTTPHEADER, [ - "x-ms-blob-type: BlockBlob", - "Content-Length: $fileSize" , - "Content-Type: multipart/form-data" + curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'PUT'); + curl_setopt($ch2, CURLOPT_POSTFIELDS, [ + 'file' => $cfile, // form field name — confirm with Vidal if this fails ]); + // Do NOT set Content-Type manually (cURL sets multipart + boundary) + if (!empty($subscriptionKey)) { + curl_setopt($ch2, CURLOPT_HTTPHEADER, [ + 'Ocp-Apim-Subscription-Key: ' . $subscriptionKey, + ]); + } $uploadResponse = curl_exec($ch2); $httpCode = curl_getinfo($ch2, CURLINFO_HTTP_CODE); $curlErr = curl_error($ch2); - fclose($fileContent); curl_close($ch2); if ($curlErr) {