@@ -17,7 +17,7 @@ This package is a wrapper bridging [aliyun-oss-flysystem](https://github.com/alp
1717- laravel/framework >= 5.5
1818
1919## Installation
20- 1 . If you use the composer to manage project dependencies, run the following command in your project' s root directory:
20+ 1 . If you use the composer to manage project dependencies, run the following command in your project" s root directory:
2121 ``` bash
2222 $ composer require alphasnow/aliyun-oss-laravel
2323 ```
@@ -33,20 +33,20 @@ This package is a wrapper bridging [aliyun-oss-flysystem](https://github.com/alp
3333
34343. (Optional) Modify the configuration file ` config/filesystems.php`
3535 ```
36- ' default' => env(' FILESYSTEM_DRIVER' , ' aliyun' ),
36+ " default" => env(" FILESYSTEM_DRIVER" , " aliyun" ),
3737 // ...
38- ' disks' => [
38+ " disks" => [
3939 // ...
40- ' aliyun' => [
41- ' driver' => ' aliyun' ,
42- ' access_id' => env(' ALIYUN_OSS_ACCESS_ID' ), // AccessKey ID, For example: LTAI4************** qgcsA
43- ' access_key' => env(' ALIYUN_OSS_ACCESS_KEY' ), // AccessKey Secret, For example: PkT4F******************** Bl9or
44- ' bucket' => env(' ALIYUN_OSS_BUCKET' ), // For example: my-storage
45- ' endpoint' => env(' ALIYUN_OSS_ENDPOINT' ), // For example: oss-cn-shanghai.aliyuncs.com
46- ' internal' => env(' ALIYUN_OSS_INTERNAL' , null), // For example: oss-cn-shanghai-internal.aliyuncs.com
47- ' domain' => env(' ALIYUN_OSS_DOMAIN' , null), // For example: oss.my-domain.com
48- ' use_ssl' => env(' ALIYUN_OSS_USE_SSL' , false), // Whether to use https
49- ' prefix' => env(' ALIYUN_OSS_PREFIX' , null), // The prefix of the store path
40+ " aliyun" => [
41+ " driver" => " aliyun" ,
42+ " access_id" => env(" ALIYUN_OSS_ACCESS_ID" ), // AccessKey ID, For example: LTAI4************** qgcsA
43+ " access_key" => env(" ALIYUN_OSS_ACCESS_KEY" ), // AccessKey Secret, For example: PkT4F******************** Bl9or
44+ " bucket" => env(" ALIYUN_OSS_BUCKET" ), // For example: my-storage
45+ " endpoint" => env(" ALIYUN_OSS_ENDPOINT" ), // For example: oss-cn-shanghai.aliyuncs.com
46+ " internal" => env(" ALIYUN_OSS_INTERNAL" , null), // For example: oss-cn-shanghai-internal.aliyuncs.com
47+ " domain" => env(" ALIYUN_OSS_DOMAIN" , null), // For example: oss.my-domain.com
48+ " use_ssl" => env(" ALIYUN_OSS_USE_SSL" , false), // Whether to use https
49+ " prefix" => env(" ALIYUN_OSS_PREFIX" , null), // The prefix of the store path
5050 ],
5151 // ...
5252 ]
@@ -55,75 +55,79 @@ This package is a wrapper bridging [aliyun-oss-flysystem](https://github.com/alp
5555# # Usage
5656` ` ` php
5757use Illuminate\S upport\F acades\S torage;
58- $storage = Storage::disk(' aliyun' );
58+ $storage = Storage::disk(" aliyun" );
5959` ` `
6060# ### Write
6161` ` ` php
62- Storage::disk(' aliyun' )-> putFile(' dir/path' , ' /local/path/file.txt' );
63- Storage::disk(' aliyun' )-> putFileAs(' dir/path' , ' /local/path/file.txt' , ' file.txt' );
62+ Storage::disk(" aliyun" )-> putFile(" dir/path" , " /local/path/file.txt" );
63+ Storage::disk(" aliyun" )-> putFileAs(" dir/path" , " /local/path/file.txt" , " file.txt" );
6464
65- Storage::disk(' aliyun' )-> put(' dir/path/file.txt' , file_get_contents(' /local/path/file.txt' ));
66- $fp = fopen(' /local/path/file.txt' , ' r ' );
67- Storage::disk(' aliyun' )-> put(' dir/path/file.txt' , $fp );
65+ Storage::disk(" aliyun" )-> put(" dir/path/file.txt" , file_get_contents(" /local/path/file.txt" ));
66+ $fp = fopen(" /local/path/file.txt" , " r " );
67+ Storage::disk(" aliyun" )-> put(" dir/path/file.txt" , $fp );
6868fclose($fp );
6969
70- Storage::disk(' aliyun' )-> prepend(' dir/path/file.txt' , ' Prepend Text' );
71- Storage::disk(' aliyun' )-> append(' dir/path/file.txt' , ' Append Text' );
70+ Storage::disk(" aliyun" )-> prepend(" dir/path/file.txt" , " Prepend Text" );
71+ Storage::disk(" aliyun" )-> append(" dir/path/file.txt" , " Append Text" );
7272
73- Storage::disk(' aliyun' )-> put(' dir/path/secret.txt' , ' My secret' , ' private' );
74- Storage::disk(' aliyun' )-> put(' dir/path/download.txt' , ' Download content' , [" headers" => [" Content-Disposition" => " attachment; filename=file .txt" ]]);
73+ Storage::disk(" aliyun" )-> put(" dir/path/secret.txt" , " My secret" , " private" );
74+ Storage::disk(" aliyun" )-> put(" dir/path/download.txt" , " Download content" , [" headers" => [" Content-Disposition" => " attachment;download .txt" ]]);
7575` ` `
7676
7777# ### Read
7878` ` ` php
79- Storage::disk(' aliyun' )-> url(' dir/path/file.txt' );
80- Storage::disk(' aliyun' )-> temporaryUrl(' dir/path/file.txt' );
81- Storage::disk(' aliyun' )-> temporaryUrl(' dir/path/file.txt' , \C arbon\C arbon::now()-> addMinutes(30));
79+ Storage::disk(" aliyun" )-> url(" dir/path/file.txt" );
80+ Storage::disk(" aliyun" )-> temporaryUrl(" dir/path/file.txt" );
81+ Storage::disk(" aliyun" )-> temporaryUrl(" dir/path/file.txt" , \C arbon\C arbon::now()-> addMinutes(30));
8282
83- Storage::disk(' aliyun' )-> get(' dir/path/file.txt' );
83+ Storage::disk(" aliyun" )-> get(" dir/path/file.txt" );
8484
85- Storage::disk(' aliyun' )-> exists(' dir/path/file.txt' );
86- Storage::disk(' aliyun' )-> size(' dir/path/file.txt' );
87- Storage::disk(' aliyun' )-> lastModified(' dir/path/file.txt' );
85+ Storage::disk(" aliyun" )-> exists(" dir/path/file.txt" );
86+ Storage::disk(" aliyun" )-> size(" dir/path/file.txt" );
87+ Storage::disk(" aliyun" )-> lastModified(" dir/path/file.txt" );
8888` ` `
8989
9090# ### Delete
9191` ` ` php
92- Storage::disk(' aliyun' )-> delete(' dir/path/file.txt' );
93- Storage::disk(' aliyun' )-> delete([' dir/path/file1.txt' , ' dir/path/file2.txt' ]);
92+ Storage::disk(" aliyun" )-> delete(" dir/path/file.txt" );
93+ Storage::disk(" aliyun" )-> delete([" dir/path/file1.txt" , " dir/path/file2.txt" ]);
9494` ` `
9595
9696# ### File operation
9797` ` ` php
98- Storage::disk(' aliyun' )-> copy(' dir/path/file.txt' , ' dir/path/file_new.txt' );
99- Storage::disk(' aliyun' )-> move(' dir/path/file.txt' , ' dir/path/file_new.txt' );
100- Storage::disk(' aliyun' )-> rename(' dir/path/file.txt' , ' dir/path/file_new.txt' );
98+ Storage::disk(" aliyun" )-> copy(" dir/path/file.txt" , " dir/path/file_new.txt" );
99+ Storage::disk(" aliyun" )-> move(" dir/path/file.txt" , " dir/path/file_new.txt" );
100+ Storage::disk(" aliyun" )-> rename(" dir/path/file.txt" , " dir/path/file_new.txt" );
101101` ` `
102102
103103# ### Folder operation
104104` ` ` php
105- Storage::disk(' aliyun' )-> makeDirectory(' dir/path' );
106- Storage::disk(' aliyun' )-> deleteDirectory(' dir/path' );
105+ Storage::disk(" aliyun" )-> makeDirectory(" dir/path" );
106+ Storage::disk(" aliyun" )-> deleteDirectory(" dir/path" );
107107
108- Storage::disk(' aliyun' )-> files(' dir/path' );
109- Storage::disk(' aliyun' )-> allFiles(' dir/path' );
108+ Storage::disk(" aliyun" )-> files(" dir/path" );
109+ Storage::disk(" aliyun" )-> allFiles(" dir/path" );
110110
111- Storage::disk(' aliyun' )-> directories(' dir/path' );
112- Storage::disk(' aliyun' )-> allDirectories(' dir/path' );
111+ Storage::disk(" aliyun" )-> directories(" dir/path" );
112+ Storage::disk(" aliyun" )-> allDirectories(" dir/path" );
113113` ` `
114114
115115# ### Use Plugin
116116` ` ` php
117- Storage::disk(' aliyun' )-> appendContent(' dir/path/news.txt' , ' The first line paragraph.' , 0);
118- Storage::disk(' aliyun' )-> appendContent(' dir/path/news.txt' , ' The second line paragraph.' , 25);
119- Storage::disk(' aliyun' )-> appendContent(' dir/path/news.txt' , ' The last line paragraph.' , 51);
117+ Storage::disk(" aliyun" )-> appendObject(" dir/path/news.txt" , " The first line paragraph." , 0);
118+ Storage::disk(" aliyun" )-> appendObject(" dir/path/news.txt" , " The second line paragraph." , 25);
119+ Storage::disk(" aliyun" )-> appendObject(" dir/path/news.txt" , " The last line paragraph." , 51);
120+
121+ Storage::disk(" aliyun" )-> appendFile(" dir/path/file.zip" , " dir/path/file.zip.001" , 0);
122+ Storage::disk(" aliyun" )-> appendFile(" dir/path/file.zip" , " dir/path/file.zip.002" , 1000);
123+ Storage::disk(" aliyun" )-> appendFile(" dir/path/file.zip" , " dir/path/file.zip.003" , 1000);
120124` ` `
121125
122126# ### Use OssClient
123127` ` ` php
124- $adapter = Storage::disk(' aliyun' )->getAdapter ();
128+ $adapter = Storage::disk(" aliyun" )->getAdapter ();
125129$client = $adapter->getClient ();
126- $client->appendObject ($adapter->getBucket (), $adapter - > applyPathPrefix( ' dir/path/file.txt ' ), ' Append Text ' , 0 );
130+ $bucketCors = $ client->getBucketCors ($adapter->getBucket ());
127131` ` `
128132
129133# # Documentation
0 commit comments