skip to Main Content

I am trying to upload a CSV file to WordPress (WooCommerce Product Importer), but it keeps saying "file type not permitted for security reasons". The thing is, I created the file myself by splitting a larger file into three. It accepted the large file (but failed later for another reason), and it also accepts the first of the three. But not the other two.

Bottom line: as soon as I save the file with LibreOfficeCalc, the mime type changes from text/plain to text/html (tested with file --mime-type myfile-2.csv) – because it primarily has a column Description with lots of HTML text.

I can’t influence the mimetype either by adding random non-HTML columns.

I can change delimiter and file encoding under "Edit filter settings" but not the mimetype. Is there a checkbox somewhere else, or a configuration I can set in some ini file to prevent this behavior?


Alternatively, how do I convert a mimetype in bash from one to the other? The answers here don’t really help because I can’t modify the request header of the upload, and gs seems to be a solution specific to PDFs.

# Ubuntu 18.04.5.
$ bash --version
> GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)

Sample data:

"wpid";"_SKU";"_name";"Description"
166678;23009;"CSM-AR9281X-99F-V1A";"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis accumsan augue. Sed fermentum, eros ac ullamcorper auctor, nunc erat sodales mauris, ut pretium ante odio et ex. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed metus sem, varius nec odio ut, vehicula ornare dolor. Proin feugiat eros vitae odio pharetra, sed suscipit augue accumsan. Sed ipsum lorem, vestibulum sed ex eu, mattis accumsan tellus. Sed interdum, sem ac molestie aliquam, nunc mi ullamcorper massa, vitae viverra metus nisi at ante. Donec id nisi lacus. Sed aliquet, ex quis interdum efficitur, nisi risus facilisis massa, in tristique libero turpis ac tortor. Etiam auctor turpis nec sodales placerat. Aenean auctor interdum felis.
<br><br>
Maecenas vel arcu quis magna suscipit tempor id et metus. Duis volutpat fringilla sem. Nulla pharetra, turpis maximus tristique fermentum, arcu arcu volutpat diam, a imperdiet turpis ante et libero. Nulla nisl elit, suscipit ac luctus id, laoreet a elit. Donec fringilla turpis id accumsan fermentum.<br>
<a href=""www.cliens.com/en/embedded-vision/cliens-sensor-modules/"">Morbi ultricies egestas commodo </a>
<br>
<p><a href=""https://support.cliens.com/en/support/solutions/48000450070"" target=""_blank""><img id=""tinymce-editor-image-8a100d4d-0c23-4a95-9a21-3c8d10050ce8"" class=""tinymce-editor-image tinymce-editor-image-8a100d4d-0c23-4a95-9a21-3c8d10050ce8"" src=""https://cliens.com/media/image/a2/8d/42/Fusce_blandit_consectetur_mattis.png"" alt=""Fusce_blandit_consectetur_mattis"" data-src=""media/image/Fusce_blandit_consectetur_mattis.png"" /></a></p>
"

UPDATE:
I could neither get it to not save as text/html by copy-pasting-saving it in Sublime-Text, nor in Google Spreadsheets (and then export). They too save as text/html. Maybe it doesn’t have as much to do with LibreOfficeCalc as I thought it would.

2

Answers


  1. Chosen as BEST ANSWER

    Given that – for whatever reason – I can save the large file as text/plain as long as I don't delete any rows, and that I only want to update existing products, I could "solve" this issue by making the rows that are not to be imported unimportable: I changed the IDs to nonexistant ones.

    I hope the documention of this weird journey can be of help to anyone someday.


  2. Another way to deal with this is to create a new column before the column that does have HTML tags and fill it for each cell with random blindcopy text that explicitly has no HTML tags; really, really long text, if necessary.

    I guess, without that workaround, the content of the other cells is too short to make the one column that does have HTML in it not dominate the file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search