Skip to content

[Bug]: to_csv() inside write do not set up ContentType for S3 #1939

@sdieguez-wotc

Description

@sdieguez-wotc

What happened?

Looks like then the S3 stream opens the blank set of chunks to upload is not providing the content-type wo the s3 object.

How to reproduce?

<?php

use function Flow\ETL\Adapter\CSV\to_csv;
use function Flow\ETL\DSL\config_builder;
use function Flow\ETL\DSL\data_frame;
use function Flow\ETL\DSL\from_rows;
use function Flow\Filesystem\Bridge\AsyncAWS\DSL\aws_s3_client;
use function Flow\Filesystem\Bridge\AsyncAWS\DSL\aws_s3_filesystem;
use function Flow\Filesystem\DSL\path;

$config = config_builder()
            ->mount(
                aws_s3_filesystem(
                    $_ENV['AWS_BUCKET'],
                    aws_s3_client([
                        'region' => $_ENV['AWS_DEFAULT_REGION'],
                        'accessKeyId' => $_ENV['AWS_ACCESS_KEY_ID'],
                        'accessKeySecret' => $_ENV['AWS_SECRET_ACCESS_KEY'],
                    ])
                )
            );

// 3. Create a DataFrame with your data
$dataFrame = data_frame([
    ['id' => 1, 'name' => 'Alice'],
    ['id' => 2, 'name' => 'Bob'],
    ['id' => 3, 'name' => 'Charlie'],
], config: $config);

// 4. Format the DataFrame as a CSV and write to the S3 stream
$dataFrame
    ->write(to_csv(path("aws-s3://{$path}"), true, ',')))
    ->run();

echo "CSV file successfully written to S3 but Content-Type: application/xml\n";

Data required to reproduce bug locally

any data

Version

Latest

Relevant error output

No error just the file uploaded is assumed to be `application/xml` even if is a csv file

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions