GWM : vidal file upload api issue fixed

This commit is contained in:
Gowtham M 2026-07-23 17:52:42 +05:30
parent 352901b9e1
commit 175d031bfb

View File

@ -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) {