-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
Storage.php
142 lines (130 loc) · 7.53 KB
/
Storage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
namespace Illuminate\Support\Facades;
use Illuminate\Filesystem\Filesystem;
/**
* @method static \Illuminate\Contracts\Filesystem\Filesystem drive(string|null $name = null)
* @method static \Illuminate\Contracts\Filesystem\Filesystem disk(string|null $name = null)
* @method static \Illuminate\Contracts\Filesystem\Cloud cloud()
* @method static \Illuminate\Contracts\Filesystem\Filesystem build(string|array $config)
* @method static \Illuminate\Contracts\Filesystem\Filesystem createLocalDriver(array $config)
* @method static \Illuminate\Contracts\Filesystem\Filesystem createFtpDriver(array $config)
* @method static \Illuminate\Contracts\Filesystem\Filesystem createSftpDriver(array $config)
* @method static \Illuminate\Contracts\Filesystem\Cloud createS3Driver(array $config)
* @method static \Illuminate\Contracts\Filesystem\Filesystem createScopedDriver(array $config)
* @method static \Illuminate\Filesystem\FilesystemManager set(string $name, mixed $disk)
* @method static string getDefaultDriver()
* @method static string getDefaultCloudDriver()
* @method static \Illuminate\Filesystem\FilesystemManager forgetDisk(array|string $disk)
* @method static void purge(string|null $name = null)
* @method static \Illuminate\Filesystem\FilesystemManager extend(string $driver, \Closure $callback)
* @method static \Illuminate\Filesystem\FilesystemManager setApplication(\Illuminate\Contracts\Foundation\Application $app)
* @method static string path(string $path)
* @method static bool exists(string $path)
* @method static string|null get(string $path)
* @method static resource|null readStream(string $path)
* @method static bool put(string $path, \Psr\Http\Message\StreamInterface|\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|resource $contents, mixed $options = [])
* @method static string|false putFile(\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|array|null $file = null, mixed $options = [])
* @method static string|false putFileAs(\Illuminate\Http\File|\Illuminate\Http\UploadedFile|string $path, \Illuminate\Http\File|\Illuminate\Http\UploadedFile|string|array|null $file, string|array|null $name = null, mixed $options = [])
* @method static bool writeStream(string $path, resource $resource, array $options = [])
* @method static string getVisibility(string $path)
* @method static bool setVisibility(string $path, string $visibility)
* @method static bool prepend(string $path, string $data)
* @method static bool append(string $path, string $data)
* @method static bool delete(string|array $paths)
* @method static bool copy(string $from, string $to)
* @method static bool move(string $from, string $to)
* @method static int size(string $path)
* @method static int lastModified(string $path)
* @method static array files(string|null $directory = null, bool $recursive = false)
* @method static array allFiles(string|null $directory = null)
* @method static array directories(string|null $directory = null, bool $recursive = false)
* @method static array allDirectories(string|null $directory = null)
* @method static bool makeDirectory(string $path)
* @method static bool deleteDirectory(string $directory)
* @method static \Illuminate\Filesystem\FilesystemAdapter assertExists(string|array $path, string|null $content = null)
* @method static \Illuminate\Filesystem\FilesystemAdapter assertMissing(string|array $path)
* @method static \Illuminate\Filesystem\FilesystemAdapter assertDirectoryEmpty(string $path)
* @method static bool missing(string $path)
* @method static bool fileExists(string $path)
* @method static bool fileMissing(string $path)
* @method static bool directoryExists(string $path)
* @method static bool directoryMissing(string $path)
* @method static array|null json(string $path, int $flags = 0)
* @method static \Symfony\Component\HttpFoundation\StreamedResponse response(string $path, string|null $name = null, array $headers = [], string|null $disposition = 'inline')
* @method static \Symfony\Component\HttpFoundation\StreamedResponse download(string $path, string|null $name = null, array $headers = [])
* @method static string|false checksum(string $path, array $options = [])
* @method static string|false mimeType(string $path)
* @method static string url(string $path)
* @method static bool providesTemporaryUrls()
* @method static string temporaryUrl(string $path, \DateTimeInterface $expiration, array $options = [])
* @method static array temporaryUploadUrl(string $path, \DateTimeInterface $expiration, array $options = [])
* @method static \League\Flysystem\FilesystemOperator getDriver()
* @method static \League\Flysystem\FilesystemAdapter getAdapter()
* @method static array getConfig()
* @method static void buildTemporaryUrlsUsing(\Closure $callback)
* @method static \Illuminate\Filesystem\FilesystemAdapter|mixed when(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null)
* @method static \Illuminate\Filesystem\FilesystemAdapter|mixed unless(\Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null)
* @method static void macro(string $name, object|callable $macro, object|callable $macro = null)
* @method static void mixin(object $mixin, bool $replace = true)
* @method static bool hasMacro(string $name)
* @method static void flushMacros()
* @method static mixed macroCall(string $method, array $parameters)
* @method static bool has(string $location)
* @method static string read(string $location)
* @method static \League\Flysystem\DirectoryListing listContents(string $location, bool $deep = false)
* @method static int fileSize(string $path)
* @method static string visibility(string $path)
* @method static void write(string $location, string $contents, array $config = [])
* @method static void createDirectory(string $location, array $config = [])
*
* @see \Illuminate\Filesystem\FilesystemManager
*/
class Storage extends Facade
{
/**
* Replace the given disk with a local testing disk.
*
* @param string|null $disk
* @param array $config
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public static function fake($disk = null, array $config = [])
{
$disk = $disk ?: static::$app['config']->get('filesystems.default');
$root = storage_path('framework/testing/disks/'.$disk);
if ($token = ParallelTesting::token()) {
$root = "{$root}_test_{$token}";
}
(new Filesystem)->cleanDirectory($root);
static::set($disk, $fake = static::createLocalDriver(array_merge($config, [
'root' => $root,
])));
return tap($fake)->buildTemporaryUrlsUsing(function ($path, $expiration) {
return URL::to($path.'?expiration='.$expiration->getTimestamp());
});
}
/**
* Replace the given disk with a persistent local testing disk.
*
* @param string|null $disk
* @param array $config
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public static function persistentFake($disk = null, array $config = [])
{
$disk = $disk ?: static::$app['config']->get('filesystems.default');
static::set($disk, $fake = static::createLocalDriver(array_merge($config, [
'root' => storage_path('framework/testing/disks/'.$disk),
])));
return $fake;
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'filesystem';
}
}