revert function to get image url
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
|
||||
<td>
|
||||
@if ($item->bukti1)
|
||||
<a href="{{ NextCloudHelper::getNextcloudFile($item->bukti1) }}" target="_blank">
|
||||
<a href="{{ NextCloudHelper::getFileUrl($item->bukti1) }}" target="_blank">
|
||||
Download
|
||||
</a>
|
||||
@else
|
||||
|
||||
Reference in New Issue
Block a user