-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cloud storage examples to homepage (#1065)
- Loading branch information
1 parent
1dd8a53
commit 44eec85
Showing
12 changed files
with
617 additions
and
460 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AWS_S3_KEY="xxxx" | ||
AWS_S3_SECRET="xxxx" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use function Flow\ETL\Adapter\CSV\to_csv; | ||
use function Flow\ETL\DSL\{data_frame, from_array, overwrite}; | ||
use Flow\ETL\Adapter\Filesystem\AwsS3Stream; | ||
use Flow\ETL\Filesystem\Path; | ||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
require __DIR__ . '/../../../autoload.php'; | ||
|
||
if (!\file_exists(__DIR__ . '/.env')) { | ||
print 'Example skipped. Please create .env file with AWS S3 credentials.' . PHP_EOL; | ||
|
||
return; | ||
} | ||
|
||
$dotenv = new Dotenv(); | ||
$dotenv->load(__DIR__ . '/.env'); | ||
|
||
$s3_client_option = [ | ||
'client' => [ | ||
'credentials' => [ | ||
'key' => $_ENV['AWS_S3_KEY'], | ||
'secret' => $_ENV['AWS_S3_SECRET'], | ||
], | ||
'region' => 'eu-west-2', | ||
'version' => 'latest', | ||
], | ||
'bucket' => 'flow-php', | ||
]; | ||
|
||
AwsS3Stream::register(); | ||
|
||
data_frame() | ||
->read(from_array([ | ||
['id' => 1, 'name' => 'test'], | ||
['id' => 2, 'name' => 'test'], | ||
['id' => 3, 'name' => 'test'], | ||
['id' => 4, 'name' => 'test'], | ||
])) | ||
->saveMode(overwrite()) | ||
->write(to_csv(new Path('flow-aws-s3://test.csv', $s3_client_option))) | ||
->run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AZURE_CONNECTION_STRING="xxxx" | ||
AZURE_CONTAINER="xxxx" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use function Flow\ETL\Adapter\CSV\to_csv; | ||
use function Flow\ETL\DSL\{data_frame, from_array, overwrite}; | ||
use Flow\ETL\Adapter\Filesystem\AzureBlobStream; | ||
use Flow\ETL\Filesystem\Path; | ||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
require __DIR__ . '/../../../autoload.php'; | ||
|
||
if (!\file_exists(__DIR__ . '/.env')) { | ||
print 'Example skipped. Please create .env file with Azure Storage Account credentials.' . PHP_EOL; | ||
|
||
return; | ||
} | ||
|
||
$dotenv = new Dotenv(); | ||
$dotenv->load(__DIR__ . '/.env'); | ||
|
||
$azure_client_option = [ | ||
'connection-string' => $_ENV['AZURE_CONNECTION_STRING'], | ||
'container' => $_ENV['AZURE_CONTAINER'], | ||
]; | ||
|
||
AzureBlobStream::register(); | ||
|
||
data_frame() | ||
->read(from_array([ | ||
['id' => 1, 'name' => 'test'], | ||
['id' => 2, 'name' => 'test'], | ||
['id' => 3, 'name' => 'test'], | ||
['id' => 4, 'name' => 'test'], | ||
])) | ||
->saveMode(overwrite()) | ||
->write(to_csv(new Path('flow-azure-blob://test.csv', $azure_client_option))) | ||
->run(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
+--------------------------------------+-------+-------+-------+--------+--------+---------+---------+---------------------------+---------------------------+----------+----------+-------------------------------------------------------+---------+-------------------------+----------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ | ||
| uuid | int_a | int_b | bool | bool_a | bool_c | float_a | float_b | datetime_d | datetime_z | string_a | string_b | array | list | json | map | object | struct | | ||
+--------------------------------------+-------+-------+-------+--------+--------+---------+---------+---------------------------+---------------------------+----------+----------+-------------------------------------------------------+---------+-------------------------+----------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ | ||
| 1fb2af91-332b-409f-b314-d26969651f1d | 1 | 1 | false | false | false | 468.02 | 75.21 | 2024-04-27T14:24:02+00:00 | 2024-04-27T14:24:02+00:00 | string | string | [{"id":1,"status":"NEW"},{"id":2,"status":"PENDING"}] | [1,2,3] | {"id":1,"status":"NEW"} | ["zero","one","two"] | ArrayIterator Object( [storage:ArrayIterator:private] => Array ( [0] => 1 [1] => 2 [2] => 3 )) | {"street":"street","city":"city","zip":"zip","country":"country","location":{"lat":1.5,"lon":1.5}} | | ||
| 06143adb-3009-45c8-a4f0-c7016f97cab7 | 1 | 1 | false | false | false | 572.91 | 210.21 | 2024-04-01T00:00:00+00:00 | 2024-04-01T00:00:00+00:00 | string | string | [{"id":1,"status":"NEW"},{"id":2,"status":"PENDING"}] | [1,2,3] | {"id":1,"status":"NEW"} | ["zero","one","two"] | ArrayIterator Object( [storage:ArrayIterator:private] => Array ( [0] => 1 [1] => 2 [2] => 3 )) | {"street":"street","city":"city","zip":"zip","country":"country","location":{"lat":1.5,"lon":1.5}} | | ||
+--------------------------------------+-------+-------+-------+--------+--------+---------+---------+---------------------------+---------------------------+----------+----------+-------------------------------------------------------+---------+-------------------------+----------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ | ||
1 rows |
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
Oops, something went wrong.