i dont know

This commit is contained in:
Lars Behrends
2025-10-20 23:40:55 +02:00
parent 552bb72370
commit 73d8441787
33 changed files with 3079 additions and 69 deletions

View File

@@ -10,7 +10,7 @@ class ImageDownloader
private Client $httpClient;
private string $basePath;
public function __construct(string $basePath = 'public/images', ?string $apiKey = null)
public function __construct(string $basePath = 'storage/images', ?string $apiKey = null)
{
$headers = [
'User-Agent' => 'MediaCollector/1.0'
@@ -25,7 +25,13 @@ class ImageDownloader
'headers' => $headers,
'verify' => false // Disable SSL verification for problematic servers
]);
$this->basePath = rtrim($basePath, '/');
// Convert relative path to absolute path
if (strpos($basePath, '/') !== 0) {
$this->basePath = __DIR__ . '/../' . $basePath;
} else {
$this->basePath = $basePath;
}
}
/**
@@ -115,6 +121,8 @@ class ImageDownloader
return true;
}
}
return false; // Not a valid image type
}
public function saveImage(string $imageData, string $filename, string $subfolder = ''): ?string
@@ -167,9 +175,9 @@ class ImageDownloader
return null;
}
// Remove the public/ prefix to get the web-accessible path
// Remove the absolute basePath prefix to get the relative path
$relativePath = str_replace($this->basePath . '/', '', $localPath);
return '/' . $relativePath;
return '/images/' . $relativePath;
}
}