当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

laravel-azure-storage

授权协议 MIT License
开发语言 PHP
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 鞠宏恺
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

laravel-azure-storage

Microsoft Azure Blob Storage integration for Laravel's Storage API.

This is a custom driver for Laravel's File Storage API, which is itself built on top of Flysystem. It uses Flysystem's own Azure blob storage adapter, and so can't easily add any more functionality than that has - indeed, adding that would be out of scope for the project.

Installation

Install the package using composer:

composer require matthewbdaly/laravel-azure-storage

On Laravel versions before 5.5 you also need to add the service provider to config/app.php manually:

Matthewbdaly\LaravelAzureStorage\AzureStorageServiceProvider::class,

Then add this to the disks section of config/filesystems.php:

'azure' => [
            'driver'    => 'azure',
            'name'      => env('AZURE_STORAGE_NAME'),
            'key'       => env('AZURE_STORAGE_KEY'),
            'container' => env('AZURE_STORAGE_CONTAINER'),
            'url'       => env('AZURE_STORAGE_URL'),
            'prefix'    => null,
        ],

Finally, add the fields AZURE_STORAGE_NAME, AZURE_STORAGE_KEY, AZURE_STORAGE_CONTAINER and AZURE_STORAGE_URL to your .env file with the appropriate credentials. The AZURE_STORAGE_URL field is optional, this allows you to set a custom URL to be returned from Storage::url(), if using the $root container the URL will be returned without the container path. A prefix can be optionally used. If it's not set, the container root is used. Then you can set the azure driver as either your default or cloud driver and use it to fetch and retrieve files as usual.

For details on how to use this driver, refer to the Laravel documentation on the file storage API.

Custom endpoints

The package supports using a custom endpoint, as in this example:

'azure' => [
            'driver'    => 'azure',
            'name'      => env('AZURE_STORAGE_NAME'),
            'key'       => env('AZURE_STORAGE_KEY'),
            'container' => env('AZURE_STORAGE_CONTAINER'),
            'url'       => env('AZURE_STORAGE_URL'),
            'prefix'    => null,
            'endpoint'  => env('AZURE_STORAGE_ENDPOINT'),
        ],

Then you can specify a suitable value for AZURE_STORAGE_ENDPOINT in your .env file as normal.

SAS token authentication

With SAS token authentication the endpoint is required. The value has the following format: https://[accountName].blob.core.windows.net

'azure' => [
            'driver'    => 'azure',
            'sasToken'  => env('AZURE_STORAGE_SAS_TOKEN'),
            'container' => env('AZURE_STORAGE_CONTAINER'),
            'url'       => env('AZURE_STORAGE_URL'),
            'prefix'    => null,
            'endpoint'  => env('AZURE_STORAGE_ENDPOINT'),
        ],

Caching

The package supports disk based caching as described in the Laravel documentation.This feature requires adding the package league/flysystem-cached-adapter:

composer require league/flysystem-cached-adapter:^1.1

To enable caching for the azure disk, add a cache directive to the disk's configuration options.

'azure' => [
            'driver'    => 'azure',
            // Other Disk Options...
            'cache'     => [
                'store' => 'memcached',
                'expire' => 600,
                'prefix' => 'filecache',
            ]
        ],

Retries

The Azure Storage SDK ships a middleware to retry failed requests.To enable the retry middewalre, add a retry directive to the disk's configuration options.

'azure' => [
            'driver'    => 'azure',
            // Other Disk Options...
            'retry'     => [
                'tries' => 3,                   // number of retries, default: 3
                'interval' => 500,              // wait interval in ms, default: 1000ms
                'increase' => 'exponential'     // how to increase the wait interval, options: linear, exponential, default: linear
            ]
        ],

Support policy

This package is supported on the current Laravel LTS version, and any later versions. If you are using an older Laravel version, it may work, but I offer no guarantees, nor will I accept pull requests to add this support.

By extension, as the current Laravel LTS version required PHP 7.0 or greater, I don't test it against PHP < 7, nor will I accept any pull requests to add this support.

  • 1.查看config下的admin.php  1)将disk修改为admin,不是则需要改成admin,或者没有的情况下需要添加. 'upload' => [ // Disk in `config/filesystem.php`. 'disk' => 'admin', // Image and file upload path under the disk above. '

  • -CentOS 7.2 64位装laravel环境----2020-2-8 1、更新操作系统 yum update -y 。。。。。。。//很多 最后显示: Replaced: NetworkManager.x86_64 1:1.4.0-20.el7_3 grub2.x86_64 1:2.02-0.34.el7.centos grub2-tools.x86_64 1:2.02-0.

  • 执行命令: laravel new logs 安装结尾抛出信息如下: symfony/var-dumper suggests installing ext-symfony_debug () symfony/translation suggests installing symfony/config () symfony/routing suggests installing symfony/con

  • 此前安装laravel的时候并未注意安装后的提示信息,只注意安装成功与否,今天在创建项目的时候发现多了很多不一样的信息,具体如下,记录一下,后面得到答案之后再做补充。 symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump) symfony/var-dumper suggests

 相关资料
  • 我刚开始使用Azure并创建了一个Linux web应用程序。 我按照域名DNS教程和设置我的域名:https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain 我使用了自定义域-文本类型 test.com不会指向应用上 /site/wwwroot的文件夹。 我把网站文件夹

  • 我试图在Laravel 5.8中实现Azure存储模拟器 它在Azure dev上工作 与公共和私有文件夹一样,我们试图将其实现为存储磁盘。我们认为只需使用相同类型的条目-而是使用. env文件中的共享密钥凭据就可以工作: 存储资源管理器已安装,可以查看Blob、队列和表。并且模拟器的状态报告: 我不知道什么样的授权头可以让它工作。 我们正在使用matthewbdaly/laravel azure

  • 我需要在nodejs中编写一个azure函数,用于压缩在azure blob存储中上传的任何文件。我有这段代码可以完成这项工作 nodejs函数的定义如下 其中myBlob包含文件的内容。 现在压缩使用流 如何将文件内容转换为流并将转换后的文件(在上面的脚本中是输出变量)保存为blob存储中但在另一个容器中的新文件? 谢谢你们

  • 介绍Azure租户ID和Client信息的获取方式 获取Azure的租户(Tenant)ID和Client信息 登录Azure控制台,单击左侧导航栏 “Azure Active Directory/应用注册” 菜单项,进入应用注册页面。建议新建一个专门的应用程序供云管平台调用Azure API。 单击 新注册 按钮,在进入的注册应用程序页面,设置名称为任意值、设置受支持的账户类型为“仅此目录中的账

  • Laravel 是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。 功能特点 1、语法更富有表现力 你知道下面这行代码里 “true” 代表什么意思么? $uri = Uri::create(‘some/uri’, array(), array(), tr

  • 我需要空间/Laravel权限的帮助。当我试图分配它给我错误哎呀,看起来像出了问题。 错误 Connection.php第761行中的QueryExcema:SQLSTATE[23000]:完整性约束冲突:1048列role_id不能为空(SQL:插入到(,)值(9,))