Add azure blob libraries and proof of concept #540

This commit is contained in:
Kendrick Chan 2021-03-22 11:02:56 +08:00
parent 3bc4bb8db7
commit ed20b421e4
5 changed files with 150 additions and 3 deletions

View file

@ -14,6 +14,7 @@
"data-dog/audit-bundle": "^0.1.10",
"edwinhoksberg/php-fcm": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"microsoft/azure-storage-blob": "^1.5",
"predis/predis": "^1.1",
"sensio/framework-extra-bundle": "^5.1",
"setasign/fpdf": "^1.8",

96
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f03b92d48946e8b2ee19466f931c826f",
"content-hash": "ad9d56a6dff26742f024917e58b919f9",
"packages": [
{
"name": "catalyst/auth-bundle",
@ -944,6 +944,7 @@
"cache",
"caching"
],
"abandoned": true,
"time": "2019-11-29T11:22:01+00:00"
},
{
@ -1611,6 +1612,7 @@
"reflection",
"static"
],
"abandoned": "roave/better-reflection",
"time": "2020-03-27T11:06:43+00:00"
},
{
@ -1901,6 +1903,94 @@
],
"time": "2014-01-12T16:20:24+00:00"
},
{
"name": "microsoft/azure-storage-blob",
"version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/Azure/azure-storage-blob-php.git",
"reference": "2475330963372d519387cb8135d6a9cfd42272da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Azure/azure-storage-blob-php/zipball/2475330963372d519387cb8135d6a9cfd42272da",
"reference": "2475330963372d519387cb8135d6a9cfd42272da",
"shasum": ""
},
"require": {
"microsoft/azure-storage-common": "~1.5",
"php": ">=5.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"MicrosoftAzure\\Storage\\Blob\\": "src/Blob"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Azure Storage PHP Client Library",
"email": "dmsh@microsoft.com"
}
],
"description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.",
"keywords": [
"azure",
"blob",
"php",
"sdk",
"storage"
],
"time": "2020-12-29T02:22:11+00:00"
},
{
"name": "microsoft/azure-storage-common",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/Azure/azure-storage-common-php.git",
"reference": "e5738035891546075bd369954e8af121d65ebd6d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Azure/azure-storage-common-php/zipball/e5738035891546075bd369954e8af121d65ebd6d",
"reference": "e5738035891546075bd369954e8af121d65ebd6d",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "~6.0|^7.0",
"php": ">=5.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"MicrosoftAzure\\Storage\\Common\\": "src/Common"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Azure Storage PHP Client Library",
"email": "dmsh@microsoft.com"
}
],
"description": "This project provides a set of common code shared by Azure Storage Blob, Table, Queue and File PHP client libraries.",
"keywords": [
"azure",
"common",
"php",
"sdk",
"storage"
],
"time": "2020-12-28T07:59:51+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.3.0",
@ -2078,12 +2168,12 @@
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
"url": "https://github.com/predis/predis.git",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"url": "https://api.github.com/repos/predis/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
},

View file

@ -113,6 +113,12 @@
"jdorn/sql-formatter": {
"version": "v1.2.17"
},
"microsoft/azure-storage-blob": {
"version": "1.5.2"
},
"microsoft/azure-storage-common": {
"version": "1.5.1"
},
"nikic/php-parser": {
"version": "v4.1.0"
},

View file

@ -0,0 +1,11 @@
DispatcheDate,Sku,SerialNumber
2020-08-07 05:32:04.537,WMGL23DL-CPNMB-L,MGS706202004
2020-08-07 05:32:04.537,WMGL23DL-CPNMB-L,MGS706202005
2020-08-07 05:32:04.537,WMGL23DL-CPNMB-L,MGS706202006
2020-08-08 09:27:14.480,WMXX26EL-CPN00-LX,MXS808202001
2020-08-08 09:31:48.737,WMXX26EL-CPN00-LX,MXS808202002
2020-08-08 10:27:08.117,WMXX26EL-CPN00-LX,MXS808202003
2020-08-08 10:41:10.060,WMXX26EL-CPN00-LX,MXS808202004
2020-08-08 10:41:10.060,WMXX26EL-CPN00-LX,MXS808202005
2020-08-08 10:41:10.060,WMXX26EL-CPN00-LX,MXS808202006
2020-10-05 13:53:57.000,ECHD26AL-SPN00-LX,CH2000012625

39
utils/test_azure/test.php Normal file
View file

@ -0,0 +1,39 @@
<?php
// NOTE: reference: https://github.com/Azure/azure-storage-php/blob/master/samples/BlobSamples.php
require_once(__DIR__ . '/../../vendor/autoload.php');
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\Common\ServiceException;
$blob_url = 'https://popappshopprodstorage.blob.core.windows.net/warranty';
$sas_token = 'sp=r&st=2021-03-18T08:26:36Z&se=2021-04-29T16:26:36Z&spr=https&sv=2020-02-10&sr=c&sig=Rwl3aCNThXEzuPjNB9sTvZzsx84ULDylyS1WtPwgyzg%3D';
$blob_url = 'https://popappshopprodstorage.blob.core.windows.net';
$sas_token = 'sp=r&st=2021-03-20T17:09:13Z&se=2021-04-01T01:09:13Z&spr=https&sv=2020-02-10&sr=c&sig=pU2fxj6eXALfGTTrsmaJ7W0QtdstyR88Xs5lvMJ35xQ%3D';
$conn_string = "BlobEndpoint=$blob_url;\nSharedAccessSignature=$sas_token";
$blob_client = BlobRestProxy::createBlobService($conn_string);
// NOTE: via download blob
$res = $blob_client->getBlob('warranty', 'Sample Result.csv');
// print_r($res);
file_put_contents("output.txt", $res->getContentStream());
/*
// NOTE: getting via url
echo $blob_client->getPsrPrimaryUri() . "\n";
$url = $blob_client->getPsrPrimaryUri() . '?' . $sas_token;
$url = $blob_url . '?' . $sas_token;
file_put_contents('output.txt', fopen($url, 'r'));
*/