grav
grav copied to clipboard
Flex Object CSV storage doesn't work (Grav\Framework\File\Formatter\CsvFormatter)
Using the class Grav\Framework\File\Formatter\CsvFormatter
throws an error.
Even after adding the media types on the system.yaml
and mime.yaml
, since it seems the errors comes from a hard-coded part of the parent class of the SimpleStorage.
The export of CSV however, works.
The code I'm using for storage is straight out of the documentation:
config:
data:
storage:
class: 'Grav\Framework\Flex\Storage\SimpleStorage'
options:
folder: user-data://flex-objects/stores.csv
formatter:
class: 'Grav\Framework\File\Formatter\CsvFormatter'
options:
file_extension: [".csv", ".tsv"]
delimiter: "," # Delimiter to separate the values
mime: "text/x-csv" # MIME type for downloading file
Do you think it has to do with trying to save the file with an appended "/" to the end of it? Look at this other issue discussed: https://github.com/getgrav/grav-plugin-data-manager/issues/43#issuecomment-1147121498
HI, I have the same error. I don't know why a
/
is appended to temp file name at row 251 ofdata-manager.php
$csv_file = File::instance($tmp . '/', $tmp_file);
The fix is remove
. '/'
:$csv_file = File::instance($tmp, $tmp_file);