acseo/cegid-rfe-connect
Composer 安装命令:
composer require acseo/cegid-rfe-connect
包简介
README 文档
README
This PHP package provides functionality to interact with Azure Blob Storage using SAS tokens. It includes authentication, listing files in a folder, and retrieving a file from storage.
📦 Installation
To install this package, run:
composer require acseo/cegid-rfe-connect
This will install all required dependencies, including:
symfony/http-clientsymfony/cachesymfony/dotenv(for testing)phpunit/phpunit(for testing)
🚀 Usage
Authentication
The Auth\Token class handles authentication and retrieves an access token from the API.
$httpClient = HttpClient::create(); $cache = new FilesystemAdapter(); $tokenService = new Auth\Token($httpClient, $cache, $clientId, $username, $password, $tokenUrl, $cacheDuration); $token = $auth->getToken();
Fetching a SAS Token
The Auth\SasToken class retrieves a SAS token to access Azure Blob Storage.
$sasTokenService = new Auth\SasToken($httpClient, $cache, $tokenService, $sasTokenUrl, $cacheDuration); $sasToken = $sasTokenService->getSasToken($tenantId, $storagePath);
Listing Files in a Folder
The RFE\Folder\ListFiles class lists files within a given folder in the blob storage.
$listFiles = new RFE\Folder\ListFiles($httpClient, $sasToken); $files = $listFiles->listFiles($'some-folder/');
Retrieving a File
The RFE\File\GetFile class fetches the contents of a file stored in Azure Blob Storage.
$getFile = new RFE\File\GetFile($httpClient, $sasToken); $fileContent = $getFile->getFile('some-folder/myfile.txt');
🧪 Running Tests
Create a .env.test file by copying the .env.test.dist template:
cp .env.test.dist .env.test
Then, update .env.test with the required values:
CLIENT_ID=your_client_id CLIENT_SECRET=your_client_secret USERNAME=your_username PASSWORD=your_password TOKEN_URL=your_token_url CACHE_DURATION=3600 SAS_TOKEN_URL=your_sas_token_url TENANT_ID=your_tenant_id STORAGE_PATH=your_storage_path FILE_PATH=your_file_path FOLDER_PATH=your_folder_path
To execute the PHPUnit test suite, run:
composer test
This will run unit tests for authentication, SAS token retrieval, file listing, and file fetching.
📌 Notes
- Ensure your
.env.testfile contains valid credentials before running tests. - Check the Azure Blob Storage permissions when using SAS tokens.
🔗 References
Enjoy using acseo/cegid-rfe-connect! 🚀
统计信息
- 总下载量: 127
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-02-03