yourwebmaker
Repos
10
Followers
38
Following
8

This is a working example of CQRS/ES in PHP. It's based on the well-known C# CQRS.nu tutorial. It uses EventSauce, but you can use any other EventSourcing package.

28
6

Events

opened issue
Reading and Writing csv files from S3 using streams

Question

I’m currently working with big files so I’m obligated to use streams and I’m trying to use CSV league combined with Flysystem. The files are stored in S3. I managed to upload a new empty file normally using the following code.

$storage = $container->get(Filesystem::class); // this is an instance League filesystem, using the S3 Adapter
$fileName = self::FILE_NAME;
$headers = [‘email’ , ‘full name’];
$stream = tmpfile();
$writer = Writer::createFromStream($stream);
$writer->insertOne($headers);
$storage->writeStream($fileName, $stream);

Porem quando tentamos adicionar novo conteudo a esse csv, nada acontece. When I try to add new content to the file created before, nothing happens, the writeStream doesn’t seem to update the file and also does not update the stream with the new content.

$storage = $container->get(Filesystem::class);
$filePath = self::FILE_NAME;
$stream = $storage->readStream($filePath);
$writer = Writer::createFromStream($stream);
$newLines = [
            [‘[mail@mail.com](mailto:mail@mail.com)’,‘manjil’],
            [‘[mail@mail.com](mailto:mail@mail.com)’,‘daniel’]
];
$writer->insertAll($newLines);
$storage->writeStream($filePath, $stream)

Is there something I’m doing wrong? When we use with local file system adapter, it works as expected because the insertAll updates the file directly which does not occur in S3.

Created at 3 weeks ago
Created at 2 months ago