grav icon indicating copy to clipboard operation
grav copied to clipboard

Flex Object CSV storage doesn't work (Grav\Framework\File\Formatter\CsvFormatter)

Open LuanHimmlisch opened this issue 2 years ago • 1 comments

Using the class Grav\Framework\File\Formatter\CsvFormatter throws an error.

CSV Error Grav CMS

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.

Parent class SimpleStorage causing errors

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

LuanHimmlisch avatar Jun 03 '22 23:06 LuanHimmlisch

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 of data-manager.php

$csv_file = File::instance($tmp . '/', $tmp_file);

The fix is remove . '/':

$csv_file = File::instance($tmp, $tmp_file);

jovaniedelacruz avatar Feb 27 '23 20:02 jovaniedelacruz