diff --git a/app/Helpers/NextCloudHelper.php b/app/Helpers/NextCloudHelper.php index 55109fb..5e7f007 100644 --- a/app/Helpers/NextCloudHelper.php +++ b/app/Helpers/NextCloudHelper.php @@ -131,34 +131,16 @@ class NextCloudHelper public static function getFileUrl($filePath) { $baseUrl = env('NEXT_CLOUD_URL'); - $publicToken = '5ogLDbQEbEMsAbD'; // Replace with your actual token - $relativePath = "/mktia/public.php/webdav/" . ltrim($filePath, '/'); + $username = env('NEXT_CLOUD_USERNAME'); - // Build the full URL - $url = rtrim($baseUrl, '/') . $relativePath . "?token={$publicToken}"; + // Build the user-specific WebDAV file URL + $relativePath = "/mktia/remote.php/dav/files/{$username}/" . ltrim($filePath, '/'); - // Initialize cURL - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'OCS-APIRequest: true', // Ensure Nextcloud recognizes the API request - ]); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disable SSL host verification - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL peer verification - - $response = curl_exec($ch); - - // Handle cURL errors - if ($response === false) { - $error = curl_error($ch); - curl_close($ch); - throw new \Exception("cURL error: {$error}"); - } - - curl_close($ch); - return $url; + // Return the full accessible URL + return rtrim($baseUrl, '/') . '/' . $relativePath; } + public static function getNextcloudFile($filePath) { // Check if the file exists diff --git a/resources/views/backend/pages/forms/upcountry/index.blade.php b/resources/views/backend/pages/forms/upcountry/index.blade.php index b69057e..a080d90 100644 --- a/resources/views/backend/pages/forms/upcountry/index.blade.php +++ b/resources/views/backend/pages/forms/upcountry/index.blade.php @@ -119,7 +119,7 @@ {{ number_format($item->total, 0, ',', '.') }} @if ($item->bukti1) - + Download @else