Claudio Fior
Posted on June 28, 2024
The new CTO like azure, so I had to access to azure storage blob and table from a php project.
The microsoft offical libraries are deprecated, so I made a the project caiofior/azure_storage using guzzle to access at this resources with a shared key.
$azureTable = new \Ftc\driver\AzureStorageTable(
AZURE_STORAGE_ACCOUNT_TABLE_NAME,
AZURE_STORAGE_ACCOUNT_TABLE_BASEURL,
AZURE_STORAGE_ACCOUNT_TABLE_TOKENSAS
);
try {
$tokenNata = $azureTable->get('file','%24filter='.urlencode('PartitionKey eq \''.$token.'\''));
} catch (\Exception $e) {
die("Token errato !");
}
Example of sorage table access
$azureBlob = new \Ftc\driver\AzureStorageBlob(
AZURE_STORAGE_ACCOUNT_FILE_NAME,
AZURE_STORAGE_ACCOUNT_FILE_BASEURL,
AZURE_STORAGE_ACCOUNT_FILE_TOKENSAS
);
$azureBlob->put(
'file',
$_FILES['uploadFile']['name'],
$_FILES['uploadFile']['type'],
$_FILES['uploadFile']['size'],
fopen($_FILES['uploadFile']['tmp_name'],'r')
);
Example of file uploading
How to generate a shared key
π πͺ π
π©
Claudio Fior
Posted on June 28, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.