Paste file in mysql blob

I am trying to insert an Open Office document in a blob field. For this I try

INSERT INTO my_table (stamp, docFile) VALUES (NOW(), LOAD_FILE('/tmp/my_file.odt')); 

This works well on Windows, but on Mac Os the file does not load in the docFile field.

Does anyone have any experience?

thanks

+6
source share
1 answer

File.separator is / or \ that is used to split the path to a specific file. For example, on Windows, this is \ or C:\Documents\Test . But on a Mac it is.

So use File.separator instead of / or \ , then it will work for both Mac and Windows.

You can update the value of a column with type 'blob'

 UPDATE `TableName` SET `ColumnName`=LOAD_FILE('FilePath/FileName.bin') WHERE `YourCondition` // FilePath -> C:/foldername/filename.bin 
+1
source

Source: https://habr.com/ru/post/907467/


All Articles