Inserting a file into Mysql (using delphi)

  • How can I insert a file (image, zip file, etc..) into mysql.

    • Is this not currently possible with Direct MySQL Objects?

    • you can use TFileStream (delphi) and use longblob fields in tables.

    • but using Direct SQL how do you do it?  All I see is a query method, but nothing that will allow me to use a stream.

    • try to save the stream to the string and then send this string as a value for some field in yours table. Works with txt 100% correctly. now i have some problems with mp3 file sending. I open mp3's like binary file into a string. I think, that the string from Filestream contains some symbols (like 'end of string' symbol)
      and thatway mysql report about some error in the string with this string.

    • This question seems to come back over and over again .. i will create a small sample tonight and will post it on sourceforge tomorrow.

      The binrary values needs to be escaped (see helpers unit), before sending it's value to the server.

      Kind regards,
      Cristian Nicola

    • Have a look at MysqlStreams in the 3rd party package. Demo project included.

      Cristian Nicola

    • m-tropolis> thanx a lot. Cristian.
      realy greate work - your library.

    • The query is limited to 1 MB?
      I try with the demo of MysqlStreams and if I choose a picture with size < 1Mb it works fine, but if picture's size > 1 Mb, the query is not executed.