39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Modules\Core\File\Contracts;
|
||
|
|
|
||
|
|
use Illuminate\Http\UploadedFile;
|
||
|
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* One storage backend's actual byte-level operations — a disk name (see
|
||
|
|
* Modules\Core\File\Models\File::$disk) resolves to exactly one
|
||
|
|
* implementation of this via Modules\Core\File\Services\FileService's own
|
||
|
|
* contextual binding (see Providers\FileServiceProvider), the same
|
||
|
|
* pattern Shipping\Contracts\CarrierFulfillmentInterface uses to pick an
|
||
|
|
* AcsFulfillmentService/BoxNowFulfillmentService per carrier. FileService
|
||
|
|
* itself never touches a disk directly — every backend-specific detail
|
||
|
|
* (a local path, an S3 bucket/region, ...) lives entirely inside one
|
||
|
|
* adapter, so adding a new backend never touches FileService or any of
|
||
|
|
* its callers.
|
||
|
|
*/
|
||
|
|
interface FileAdapterInterface
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Stores the file under $directory, returning the path to record on
|
||
|
|
* the File row (Models\File::$path) — backend-specific (a relative
|
||
|
|
* local path, an S3 object key, ...), meaningful only to this same
|
||
|
|
* adapter.
|
||
|
|
*/
|
||
|
|
public function store(UploadedFile $file, string $directory): string;
|
||
|
|
|
||
|
|
public function exists(string $path): bool;
|
||
|
|
|
||
|
|
public function delete(string $path): void;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Streams the file at $path straight to the browser.
|
||
|
|
*/
|
||
|
|
public function retrieve(string $path, ?string $name = null): StreamedResponse;
|
||
|
|
}
|