@@ -21,7 +21,7 @@ If client direct transmission is required, Use web server signature direct trans
2121| \> =9.0 | ^4.0 | [ readme] ( https://github.com/alphasnow/aliyun-oss-laravel/blob/master/README.md ) |
2222
2323## Installation
24- 1 . If you use the composer to manage project dependencies, run the following command in your project' s root directory:
24+ 1 . If you use the composer to manage project dependencies, run the following command in your project" s root directory:
2525 ``` bash
2626 composer require alphasnow/aliyun-oss-laravel
2727 ```
@@ -37,21 +37,21 @@ If client direct transmission is required, Use web server signature direct trans
3737
3838 1. (Optional) Modify the configuration file ` config/filesystems.php`
3939 ` ` ` php
40- ' default' => env(' FILESYSTEM_DRIVER' , ' oss' ),
40+ " default" => env(" FILESYSTEM_DRIVER" , " oss" ),
4141 // ...
42- ' disks' => [
42+ " disks" => [
4343 // ...
44- ' oss' => [
45- ' driver' => ' oss' ,
46- ' access_key_id' => env(' OSS_ACCESS_KEY_ID' ), // Required, YourAccessKeyId
47- ' access_key_secret' => env(' OSS_ACCESS_KEY_SECRET' ), // Required, YourAccessKeySecret
48- ' bucket' => env(' OSS_BUCKET' ), // Required, For example: my-bucket
49- ' endpoint' => env(' OSS_ENDPOINT' ), // Required, For example: oss-cn-shanghai.aliyuncs.com
50- ' internal' => env(' OSS_INTERNAL' , null), // Optional, For example: oss-cn-shanghai-internal.aliyuncs.com
51- ' domain' => env(' OSS_DOMAIN' , null), // Optional, For example: oss.my-domain.com
52- ' use_ssl' => env(' OSS_SSL' , false), // Optional, Whether to use HTTPS
53- ' prefix' => env(' OSS_PREFIX' , ' ' ), // Optional, The prefix of the store path
54- ' reverse_proxy' => env(' OSS_REVERSE_PROXY' , false), // Optional, Nginx reverse proxy domain
44+ " oss" => [
45+ " driver" => " oss" ,
46+ " access_key_id" => env(" OSS_ACCESS_KEY_ID" ), // Required, YourAccessKeyId
47+ " access_key_secret" => env(" OSS_ACCESS_KEY_SECRET" ), // Required, YourAccessKeySecret
48+ " bucket" => env(" OSS_BUCKET" ), // Required, For example: my-bucket
49+ " endpoint" => env(" OSS_ENDPOINT" ), // Required, For example: oss-cn-shanghai.aliyuncs.com
50+ " internal" => env(" OSS_INTERNAL" , null), // Optional, For example: oss-cn-shanghai-internal.aliyuncs.com
51+ " domain" => env(" OSS_DOMAIN" , null), // Optional, For example: oss.my-domain.com
52+ " use_ssl" => env(" OSS_SSL" , false), // Optional, Whether to use HTTPS
53+ " prefix" => env(" OSS_PREFIX" , " " ), // Optional, The prefix of the store path
54+ " reverse_proxy" => env(" OSS_REVERSE_PROXY" , false), // Optional, Nginx reverse proxy domain
5555 ],
5656 // ...
5757 ]
@@ -60,71 +60,77 @@ If client direct transmission is required, Use web server signature direct trans
6060# # Usage
6161` ` ` php
6262use Illuminate\S upport\F acades\S torage;
63- $storage = Storage::disk(' oss' );
63+ $storage = Storage::disk(" oss" );
6464` ` `
6565# ### Write
6666` ` ` php
67- Storage::disk(' oss' )-> putFile(' dir/path' , ' /local/path/file.txt' );
68- Storage::disk(' oss' )-> putFileAs(' dir/path' , ' /local/path/file.txt' , ' file.txt' );
67+ Storage::disk(" oss" )-> putFile(" dir/path" , " /local/path/file.txt" );
68+ Storage::disk(" oss" )-> putFileAs(" dir/path" , " /local/path/file.txt" , " file.txt" );
6969
70- Storage::disk(' oss' )-> put(' dir/path/file.txt' , file_get_contents(' /local/path/file.txt' ));
71- $fp = fopen(' /local/path/file.txt' , ' r ' );
72- Storage::disk(' oss' )-> put(' dir/path/file.txt' , $fp );
70+ Storage::disk(" oss" )-> put(" dir/path/file.txt" , file_get_contents(" /local/path/file.txt" ));
71+ $fp = fopen(" /local/path/file.txt" , " r " );
72+ Storage::disk(" oss" )-> put(" dir/path/file.txt" , $fp );
7373fclose($fp );
7474
75- Storage::disk(' oss' )-> prepend(' dir/path/file.txt' , ' Prepend Text' );
76- Storage::disk(' oss' )-> append(' dir/path/file.txt' , ' Append Text' );
75+ Storage::disk(" oss" )-> prepend(" dir/path/file.txt" , " Prepend Text" );
76+ Storage::disk(" oss" )-> append(" dir/path/file.txt" , " Append Text" );
7777
78- Storage::disk(' oss' )-> put(' dir/path/secret.txt' , ' My secret' , ' private' );
79- Storage::disk(' oss' )-> put(' dir/path/download.txt' , ' Download content' , [" headers" => [" Content-Disposition" => " attachment; filename=download.txt" ]]);
78+ Storage::disk(" oss" )-> put(" dir/path/secret.txt" , " My secret" , " private" );
79+ Storage::disk(" oss" )-> put(" dir/path/download.txt" , " Download content" , [" headers" => [" Content-Disposition" => " attachment; filename=download.txt" ]]);
8080` ` `
8181
8282# ### Read
8383` ` ` php
84- Storage::disk(' oss' )-> url(' dir/path/file.txt' );
85- Storage::disk(' oss' )-> temporaryUrl(' dir/path/file.txt' , \C arbon\C arbon::now()-> addMinutes(30));
84+ Storage::disk(" oss" )-> url(" dir/path/file.txt" );
85+ Storage::disk(" oss" )-> temporaryUrl(" dir/path/file.txt" , \C arbon\C arbon::now()-> addMinutes(30));
8686
87- Storage::disk(' oss' )-> get(' dir/path/file.txt' );
87+ Storage::disk(" oss" )-> get(" dir/path/file.txt" );
8888
89- Storage::disk(' oss' )-> exists(' dir/path/file.txt' );
90- Storage::disk(' oss' )-> size(' dir/path/file.txt' );
91- Storage::disk(' oss' )-> lastModified(' dir/path/file.txt' );
89+ Storage::disk(" oss" )-> exists(" dir/path/file.txt" );
90+ Storage::disk(" oss" )-> size(" dir/path/file.txt" );
91+ Storage::disk(" oss" )-> lastModified(" dir/path/file.txt" );
9292` ` `
9393
9494# ### Delete
9595` ` ` php
96- Storage::disk(' oss' )-> delete(' dir/path/file.txt' );
97- Storage::disk(' oss' )-> delete([' dir/path/file1.txt' , ' dir/path/file2.txt' ]);
96+ Storage::disk(" oss" )-> delete(" dir/path/file.txt" );
97+ Storage::disk(" oss" )-> delete([" dir/path/file1.txt" , " dir/path/file2.txt" ]);
9898` ` `
9999
100100# ### File operation
101101` ` ` php
102- Storage::disk(' oss' )-> copy(' dir/path/file.txt' , ' dir/path/file_new.txt' );
103- Storage::disk(' oss' )-> move(' dir/path/file.txt' , ' dir/path/file_new.txt' );
104- Storage::disk(' oss' )-> rename(' dir/path/file.txt' , ' dir/path/file_new.txt' );
102+ Storage::disk(" oss" )-> copy(" dir/path/file.txt" , " dir/path/file_new.txt" );
103+ Storage::disk(" oss" )-> move(" dir/path/file.txt" , " dir/path/file_new.txt" );
104+ Storage::disk(" oss" )-> rename(" dir/path/file.txt" , " dir/path/file_new.txt" );
105105` ` `
106106
107107# ### Folder operation
108108` ` ` php
109- Storage::disk(' oss' )-> makeDirectory(' dir/path' );
110- Storage::disk(' oss' )-> deleteDirectory(' dir/path' );
109+ Storage::disk(" oss" )-> makeDirectory(" dir/path" );
110+ Storage::disk(" oss" )-> deleteDirectory(" dir/path" );
111111
112- Storage::disk(' oss' )-> files(' dir/path' );
113- Storage::disk(' oss' )-> allFiles(' dir/path' );
112+ Storage::disk(" oss" )-> files(" dir/path" );
113+ Storage::disk(" oss" )-> allFiles(" dir/path" );
114114
115- Storage::disk(' oss' )-> directories(' dir/path' );
116- Storage::disk(' oss' )-> allDirectories(' dir/path' );
115+ Storage::disk(" oss" )-> directories(" dir/path" );
116+ Storage::disk(" oss" )-> allDirectories(" dir/path" );
117117` ` `
118118
119119# ### Use Macro
120120` ` ` php
121- Storage::disk(' oss' )-> appendObject(' dir/path/news.txt' , ' The first line paragraph.' , 0);
122- Storage::disk(' oss' )-> appendObject(' dir/path/news.txt' , ' The second line paragraph.' , 25);
123- Storage::disk(' oss' )-> appendObject(' dir/path/news.txt' , ' The last line paragraph.' , 51);
121+ Storage::disk(" oss" )-> appendObject(" dir/path/news.txt" , " The first line paragraph." , 0);
122+ Storage::disk(" oss" )-> appendObject(" dir/path/news.txt" , " The second line paragraph." , 25);
123+ Storage::disk(" oss" )-> appendObject(" dir/path/news.txt" , " The last line paragraph." , 51);
124124
125- $position = Storage::disk(' oss' )-> appendFile(' dir/path/file.zip' , ' dir/path/file.zip.001' , 0);
126- $position = Storage::disk(' oss' )-> appendFile(' dir/path/file.zip' , ' dir/path/file.zip.002' , $position );
127- $position = Storage::disk(' oss' )-> appendFile(' dir/path/file.zip' , ' dir/path/file.zip.003' , $position );
125+ $position = Storage::disk(" oss" )-> appendFile(" dir/path/file.zip" , " dir/path/file.zip.001" , 0);
126+ $position = Storage::disk(" oss" )-> appendFile(" dir/path/file.zip" , " dir/path/file.zip.002" , $position );
127+ $position = Storage::disk(" oss" )-> appendFile(" dir/path/file.zip" , " dir/path/file.zip.003" , $position );
128+ ` ` `
129+
130+ # ### Use `OssClient`
131+ ` ` ` php
132+ $client = Storage::disk("oss")->getAdapter()->getClient ();
133+ $bucketCors = $client -> getBucketCors(" bucket-name" )
128134` ` `
129135
130136# # Documentation
0 commit comments