mysql db image convert to file - mysql

Hi i am writing a converter from Oracle to mysql
In Oracle the images are stored in db.
I want to read the content of the image and save to file system
I suppose that i have to read the blob entry and using php file commands create the file (am i right)
What about image type. Should i save as jpg (what if the store image is not jpg)
Any suggestion are welcome

you can write the blob directly to a file on disk. you can exclude the file extension from the name if you don't have that information somewhere in the db or the app. you could also deduce the content type by using the unix file command if you really need to assign an extension.

Related

CSV open>edit>save from Webserver using HTML/JS/PHP

I am using jquery.datatable.editable and I want this datatable to get the main data from a simple CSV-file stored on the webserver. This is shown possible with CSV to HTML Table.
When I edit a cell inside jquery.datatable.editable I want it to update the CSV-file stored on my webserver. How can I do this?
I also checked vscode-edit-csv and love the layout as an editing interface but it only seams that it opens the file from a local stored file and not from the server...
(Some people use mySQL but I want to use a flat file (CSV) instead for syncing reasons.)

How to retrieve original pdf stored as MySQL mediumblob?

A table containing almost four thousand records includes a mediumblob field for each record that contains the record's associated PDF report. Under both MySQL Workbench and phpMyAdmin the relevant DOCUMENT column displays the data as a BLOB button or link. In the case of phpMyAdmin the link also indicates the size of the data the Blob contains.
The issue is that when the Blob button/link is clicked, under MySQL Workbench opening any of the files using the SQL Editor only displays the raw Blob data and under phpMyAdmin th link only allows the Blob data to be saved as a .bin file instead of displaying or saving the data as a viewable PDF file. All previous attempts to retrieve the original PDFs using PHP have failed - see related earlier thread: Extract Pdf from MySql Dump Saved as Text.
The filename field in the table shows that all the stored files are PDF files. Further research and tests indicate that the mediumblob data has been stored as application/octet-streams.
My question is how can the original PDFs be retrieved as readable PDFs? Is it possible for a .bin file saved from the database to be converted or used to recover the original PDF file?
Any assistance would be greatly appreciated.
In line with my assumption and Isaac's suggestion the only solution was to be able to speak to one of the software developers. It transpires that the documents have been zipped using an third-party library as well as the header being removed before then being stored in the database.
The third-party library used is version 2.0.50727 of Chilkat, available from www.chilkatsoft.com. That version no longer appears to be available, but hopefully at least one of the later versions may do the job.
Thanks again for everyone's input and assistance.
Based on the discussion in the comments, it sounds like you'll need to either refer to the original source code or consult with the original developer to determine exactly how the data was stored.
Using phpMyAdmin to download the mediumblob data as a file will download a .bin file in many cases, I actually don't recall how it determines content type (for instance, a PNG file will download with a .png extension, but most other binary files simply download as a .bin when phpMyAdmin isn't sure what the extension should be, PDF included). So the behavior you're seeing from phpMyAdmin is expected and correct, but since the .bin file doesn't work when it's renamed to .pdf that means something has probably gone wrong with the import and upload.
BLOB data is often stored in a pretty standardized way, but it seems your data doesn't follow that method.
Without us seeing the code directly, we can't guess what exactly happened with storing the data and would only be guessing.

Nodejs/Express Save select avatar from web client and save directly to MySQL Database

Looking for some guidance here. I am building Nodejs/Express app with MySQL Database. I want to be able to click on the users image on the web page (initial image is generic), select a different image and upload/save new image into MySQL database. I using:
$('#file-input').trigger('click').change (function(){
alert($('#file-input').val());
})
I get C:/fakepath... for image location. I would like to how to upload/save selected image to the MySQL database. Connection to database is established, and routes for regular data work just fine.
Before answering your question will suggest you to not save image into your MySql or any database, use IPFS, local application directory/folder, or best AWS s3 bucket.
You can use busboy.js NPM module or multer.js NPM module for file upload to server, there's lots of good reason to not save any kind of file in local database.
Now back to how you can save image in database. You can do so by first converting your image to a data format your MySql understand. By default image is binary and depending upon image selected some image binary is so big that even MySql text datatype is small for them. Converting binary to hexadecimal does help but still too big for MySql text datatype. Also you will need multipart/form-data for file upload.
You can easily find "How to upload file in nodeJs?" in a google search. Still if need an example here's one "Upload file using multer.js"

How to store and retrive image data in MySQL database in Golang

How can I insert an image data in MySQL Database and then retrieve it using Golang?
Basically I want that task for upload profile picture of user in web application.
According to the my knowledge,the best solution is save image as blob object in database.Is it best solution for upload image in webapplication in golang.?
Please help me find the best solution for that.I want to find the solution in golang.I am beginner for golang programming.
converting image to a blob and save it in the database is a somewhat long process and it may cause issues sometimes. The easiest way is saving the image to a server (or a local directory) and saving the image path in the database. In that way we can access the image by using the image path in the database. This, will show how to save image path and access it and converting image to a blob and save it in the database.
Here

adding image files to database table

how to add image file/s to mysql table.I am a programmer I am using php and mysql.
You shouldn't add the image itself for websites. You upload the image to the server and then save the path into the database. You should be able to then output the path of the file to HTML.
You need to use blob (or mediumblob or longblob depending on the maximum size of images you want to support) data type for storing binary data.
Before inserting, be sure to escape special characters in the binary image data.
$img_data =mysql_real_escape_string(file_get_contents($filename));
I usually store the url of the image file rather than the file itself (not too sure how you would do that anyway). I recommend storing the url and using