承接 bornmt/azure-blob-url-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bornmt/azure-blob-url-generator

Composer 安装命令:

composer require bornmt/azure-blob-url-generator

包简介

Azure Blob SAS URL generator for Laravel and Spatie MediaLibrary

README 文档

README

A Laravel package that provides Azure Blob Storage URL generation with SAS (Shared Access Signature) tokens for Spatie Laravel Media Library.

This package extends Spatie's default URL generator to produce Azure Blob Storage URLs with SAS token authentication, enabling secure access to media files stored in Azure Blob Storage.

Requirements

Installation

Install the package via Composer:

composer require bornmt/azure-blob-url-generator

Register the Service Provider

If you're using Laravel 11+, the service provider may be auto-discovered. Otherwise, add it to the providers array in config/app.php:

'providers' => [
    // ...
    BornMT\AzureBlobUrlGenerator\UrlGeneratorServiceProvider::class,
],

Configuration

1. Environment Variables

Add the following variables to your .env file:

AZURE_STORAGE_ENDPOINT=https://yourstorageaccount.blob.core.windows.net
AZURE_STORAGE_CONTAINER=your-container-name
AZURE_STORAGE_SAS_TOKEN=sv=2021-06-08&ss=b&srt=sco&sp=rl&se=...
Variable Description
AZURE_STORAGE_ENDPOINT The full URL of your Azure Storage account (e.g., https://mystorageaccount.blob.core.windows.net)
AZURE_STORAGE_CONTAINER The name of the blob container where media files are stored
AZURE_STORAGE_SAS_TOKEN The SAS token string (without the leading ?) for authenticated access

Note: Ensure your SAS token has appropriate permissions (e.g., r for read access) and is configured with a suitable expiration for your use case.

2. Configure Spatie Media Library

Update your Spatie Media Library configuration to use this package's URL generator. Publish the media library config if you haven't already:

php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-config"

Then, in config/media-library.php, set the custom URL generator:

'url_generator' => \BornMT\AzureBlobUrlGenerator\Services\UrlGeneratorService::class,

3. Configure Your Filesystem

Add the Azure disk to config/filesystems.php:

'disks' => [
    'azure' => [
        'driver' => 'azure-storage-blob',
        'sasToken' => env('AZURE_STORAGE_SAS_TOKEN'),
        'container' => env('AZURE_STORAGE_CONTAINER'),
        'endpoint' => env('AZURE_STORAGE_ENDPOINT'),
        'connection_string' => sprintf(
            'BlobEndpoint=%s;SharedAccessSignature=%s',
            env('AZURE_STORAGE_ENDPOINT'),
            env('AZURE_STORAGE_SAS_TOKEN')
        ),
    ],
],

Set your default media disk in config/media-library.php or via the MEDIA_DISK environment variable:

MEDIA_DISK=azure

Usage

Once configured, media URLs are generated automatically when you call getUrl() or getTemporaryUrl() on your media items.

Basic Usage with Spatie Media Library

// Add media to a model
$yourModel->addMedia($pathToFile)
    ->toMediaCollection('documents', 'azure');

// Get the Azure Blob SAS URL
$media = $yourModel->getFirstMedia('documents');
$url = $media->getUrl();  // Returns full URL with SAS token

// Get a temporary URL (uses same SAS token - ensure your SAS has appropriate expiration)
$temporaryUrl = $media->getTemporaryUrl(now()->addHours(1));

Generated URL Format

URLs are generated in the following format:

{endpoint}/{container}/{path-to-file}?{sas_token}

Example:

https://mystorageaccount.blob.core.windows.net/my-container/media/1/image.jpg?sv=2021-06-08&ss=b&srt=sco&sp=rl&se=...

License

The MIT License (MIT). Please see the License File for more information.

bornmt/azure-blob-url-generator 适用场景与选型建议

bornmt/azure-blob-url-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 131 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「url」 「azure」 「blob」 「SAS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bornmt/azure-blob-url-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bornmt/azure-blob-url-generator 我们能提供哪些服务?
定制开发 / 二次开发

基于 bornmt/azure-blob-url-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 131
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-05