Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions config/s3server.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* @author Marcel Menk <marcel.menk@ipvx.io>
*/
return [
'auth' => true,
'auth_driver' => LaravelS3Server\Drivers\DatabaseAuthenticationDriver::class,
'storage_driver' => LaravelS3Server\Drivers\FileStorageDriver::class,
'auth' => env('S3SERVER_AUTH', true),
'auth_driver' => env('S3SERVER_AUTH_DRIVER', LaravelS3Server\Drivers\DatabaseAuthenticationDriver::class),
'storage_driver' => env('S3SERVER_STORAGE_DRIVER', LaravelS3Server\Drivers\FileStorageDriver::class),
'storage_path' => env('S3SERVER_STORAGE_PATH', 's3/'),
];
14 changes: 7 additions & 7 deletions src/Drivers/FileStorageDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FileStorageDriver implements S3StorageDriver
*/
public function get(string $path): ?string
{
return Storage::get($path);
return Storage::get(config('s3server.storage_path') . $path);
}

/**
Expand All @@ -39,7 +39,7 @@ public function put(string $path, string $content): void
// Ensure the directory structure exists before writing the file
$this->ensureDirectoryExists($path);

Storage::put($path, $content);
Storage::put(config('s3server.storage_path') . $path, $content);
}

/**
Expand All @@ -49,8 +49,8 @@ public function put(string $path, string $content): void
*/
public function delete(string $path): void
{
Storage::deleteDirectory($path);
Storage::delete($path);
Storage::deleteDirectory(config('s3server.storage_path') . $path);
Storage::delete(config('s3server.storage_path') . $path);
}

/**
Expand All @@ -76,7 +76,7 @@ public function list(string $prefix, array $options = []): array
}

// Get all files under the search prefix
$allFiles = Storage::allFiles($searchPrefix);
$allFiles = Storage::allFiles(config('s3server.storage_path') . $searchPrefix);

if ($recursive) {
// Return all files recursively, filtered by the query prefix
Expand Down Expand Up @@ -169,8 +169,8 @@ private function ensureDirectoryExists(string $path): void
}

// Create the directory if it doesn't exist
if (!Storage::exists($directory)) {
Storage::makeDirectory($directory);
if (!Storage::exists(config('s3server.storage_path') . $directory)) {
Storage::makeDirectory(config('s3server.storage_path') . $directory);
}
}
}
2 changes: 1 addition & 1 deletion src/Services/S3RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle(Request $request, string $bucket, ?string $key = null): R

return match ($method) {
'PUT' => $this->putObject($bucket, $key, $request),
'GET' => !Storage::directoryExists($bucket . '/' . $key) && $key ?
'GET' => !Storage::directoryExists(config('s3server.storage_path') . $bucket . '/' . $key) && $key ?
$this->getObject($bucket, $key) :
$this->listBucket($bucket, $key),
'HEAD' => $this->headObject($bucket, $key),
Expand Down