Last active
July 21, 2024 14:43
-
-
Save norberttech/53ce0548842bf10173aa2087b90c9bf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use function Flow\Azure\SDK\DSL\azure_blob_service; | |
use function Flow\Azure\SDK\DSL\azure_blob_service_config; | |
use function Flow\Azure\SDK\DSL\azure_shared_key_authorization_factory; | |
use function Flow\Filesystem\Bridge\Azure\DSL\azure_filesystem; | |
use function Flow\Filesystem\Bridge\Azure\DSL\azure_filesystem_options; | |
use function Flow\Filesystem\DSL\fstab; | |
use function Flow\Filesystem\DSL\path; | |
use function Flow\Filesystem\DSL\protocol; | |
require __DIR__ . '/vendor/autoload.php'; | |
$account = $_ENV['AZURE_STORAGE_ACCOUNT']; | |
$accountKey = $_ENV['AZURE_STORAGE_ACCOUNT_KEY']; | |
$container = $_ENV['AZURE_STORAGE_CONTAINER']; | |
$fstab = fstab( | |
azure_filesystem( | |
azure_blob_service( | |
azure_blob_service_config($account, $container), | |
azure_shared_key_authorization_factory($account, $accountKey), | |
), | |
azure_filesystem_options() | |
) | |
); | |
$stream = $fstab->for(protocol('azure-blob'))->writeTo(path('azure-blob://orders.csv')); | |
$stream->append('id,name,active'); | |
$stream->append('1,norbert,true'); | |
$stream->append('2,john,true'); | |
$stream->append('3,jane,true'); | |
$stream->close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php | |
use function Flow\Azure\SDK\DSL\{azure_blob_service, azure_blob_service_config, azure_shared_key_authorization_factory}; | |
use function Flow\Filesystem\Bridge\Azure\DSL\{azure_filesystem, azure_filesystem_options}; | |
use function Flow\Filesystem\DSL\{fstab, path, protocol}; | |
require __DIR__ . '/vendor/autoload.php'; | |
$account = $_ENV['AZURE_STORAGE_ACCOUNT']; | |
$accountKey = $_ENV['AZURE_STORAGE_ACCOUNT_KEY']; | |
$container = $_ENV['AZURE_STORAGE_CONTAINER']; | |
$fstab = fstab( | |
azure_filesystem( | |
azure_blob_service( | |
azure_blob_service_config($account, $container), | |
azure_shared_key_authorization_factory($account, $accountKey), | |
), | |
azure_filesystem_options() | |
) | |
); | |
$stream = $fstab->for(protocol('azure-blob'))->writeTo(path('azure-blob://orders.csv')); | |
$stream->append('id,name,active'); | |
$stream->append('1,norbert,true'); | |
$stream->append('2,john,true'); | |
$stream->append('3,jane,true'); | |
$stream->close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Flow\Azure\SDK\AuthorizationFactory\SharedKeyFactory; | |
use Flow\Azure\SDK\BlobService; | |
use Flow\Azure\SDK\BlobService\Configuration; | |
use Flow\Azure\SDK\HttpFactory; | |
use Flow\Filesystem\Bridge\Azure\AzureBlobFilesystem; | |
use Flow\Filesystem\Bridge\Azure\Options; | |
use Flow\Filesystem\FilesystemTable; | |
use Flow\Filesystem\Path; | |
use Flow\Filesystem\Protocol; | |
use Http\Discovery\Psr17FactoryDiscovery; | |
use Http\Discovery\Psr18ClientDiscovery; | |
use Psr\Log\NullLogger; | |
require __DIR__ . '/../../vendor/autoload.php'; | |
$account = $_ENV['AZURE_STORAGE_ACCOUNT']; | |
$accountKey = $_ENV['AZURE_STORAGE_ACCOUNT_KEY']; | |
$container = $_ENV['AZURE_STORAGE_CONTAINER']; | |
$fstab = new FilesystemTable( | |
new AzureBlobFilesystem( | |
new BlobService( | |
new Configuration($account, $container), | |
Psr18ClientDiscovery::find(), | |
new HttpFactory(Psr17FactoryDiscovery::findRequestFactory(), Psr17FactoryDiscovery::findStreamFactory()), | |
new BlobService\URLFactory\AzureURLFactory(), | |
new SharedKeyFactory($account, $accountKey), | |
new NullLogger(), | |
), | |
new Options() | |
) | |
); | |
$stream = $fstab->for(new Protocol('azure-blob'))->writeTo(new Path('azure-blob://orders.csv')); | |
$stream->append('id,name,active'); | |
$stream->append('1,norbert,true'); | |
$stream->append('2,john,true'); | |
$stream->append('3,jane,true'); | |
$stream->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment