获取从 S3 读取 CSV "stream does not support seeking"



使用LeagueCSV"9.6〃;

在我的本地服务器上读取CSV文件时,leaguecsv工作得很好。我已经将CSV文件移到S3进行生产,现在我得到了一个";seek";调用getHeader((时出错。

";{消息:"流不支持查找",异常:"League \Csv\exception",…}">

在得到查找错误后,我尝试了以下更改,我在Github上看到了如下更改,但没有任何帮助:

$s3Client = AwsS3S3Client::factory(array(
'version' => 'latest',
'region' => env('AWS_DEFAULT_REGION'),
'credentials' => array(
'key'    => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
),
));

$s3Client->registerStreamWrapper();
$context = stream_context_create(array(
's3' => array(
'seekable' => true
)
));

我还从createFromPath(当文件在本地服务器上时工作(更改为S3的createFromStream

//load the CSV document from a file path
//$csv = Reader::createFromPath($FileNameOnEC2, 'r');  <<--this worked fine when the file was on the local server
$stream = fopen($FileNameOnS3, 'r', false, $context);
$csv = LeagueCsvReader::createFromStream($stream);
$csv->setHeaderOffset(0);
$header = $csv->getHeader(); //returns the CSV header record // <<-- calling this causes the error 
$records = $csv->getRecords(); 
$content = $csv->getContent();

$stmt = (new Statement());
$records = $stmt->process($csv);

有人看到这个问题吗

我遇到了同样的问题,这是由flysystem-aws-s3-v3 v1.28中的BC引起的https://github.com/thephpleague/flysystem-aws-s3-v3/commit/c73ebc5b78076e971ec64fdab8a5a956d118b160

请参阅https://github.com/thephpleague/flysystem-aws-s3-v3/issues/218.我目前已将版本修复为v1.0.27。

相关内容

最新更新