在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Superbalist/laravel-google-cloud-storage开源软件地址(OpenSource Url):https://github.com/Superbalist/laravel-google-cloud-storage开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):laravel-google-cloud-storageA Google Cloud Storage filesystem for Laravel. This package is a wrapper bridging flysystem-google-storage into Laravel as an available storage disk. Installationcomposer require superbalist/laravel-google-cloud-storage If you are on Laravel 5.4 or earlier, then register the service provider in app.php 'providers' => [
// ...
Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,
] If you are on Laravel 5.5 or higher, composer will have registered the provider automatically for you. Add a new disk to your 'gcs' => [
'driver' => 'gcs',
'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
'key_file' => env('GOOGLE_CLOUD_KEY_FILE', null), // optional: /path/to/service-account.json
'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket
'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
'visibility' => 'public', // optional: public|private
], AuthenticationThe Google Client uses a few methods to determine how it should authenticate with the Google API.
Public URLsThe adapter implements a
$disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/folder/my_file.txt If you configure a $disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://storage.googleapis.com/bucket-name/path-prefix/folder/my_file.txt If you configure a custom $disk = Storage::disk('gcs');
$url = $disk->url('folder/my_file.txt');
>>> http://your-custom-domain.com/bucket-name/path-prefix/folder/my_file.txt For a custom domain (storage api uri), you will need to configure a CNAME DNS entry pointing to Please see https://cloud.google.com/storage/docs/xml-api/reference-uris#cname for further instructions. Usage$disk = Storage::disk('gcs');
// create a file
$disk->put('avatars/1', $fileContents);
// check if a file exists
$exists = $disk->exists('file.jpg');
// get file modification date
$time = $disk->lastModified('file1.jpg');
// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');
// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');
// get url to file
$url = $disk->url('folder/my_file.txt');
// Set the visibility of file to public
$disk->setVisibility('folder/my_file.txt', 'public');
// See https://laravel.com/docs/5.3/filesystem for full list of available functionality |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论