I'm uploading images to a database in Blobs but the file names are being changed to database_name-table_name.bin.png
which is not so good.
Is there anyway to preserve the name that the application that uploads them uses?
The java code (prepared statement) I use to upload them is:
FileInputStream inputStream = null;
// Directory with the name i want to use
File image = new File(CreateArticleController.articleDetails.get("introImg"));
inputStream = new FileInputStream(image);
pstmt.setBinaryStream(7, (InputStream) inputStream,(int) (image.length()));
Database:
CREATE TABLE IF NOT EXISTS `temp_article` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`author` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`author_id` int(10) NOT NULL,
`type` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`wfurl` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`intro` text COLLATE utf8_unicode_ci NOT NULL,
`intro_image` mediumblob NOT NULL,
`status` int(10) NOT NULL DEFAULT '0',
`main_image` mediumblob NOT NULL,
`content_1` text COLLATE utf8_unicode_ci,
`image_1` mediumblob,
`content_2` text COLLATE utf8_unicode_ci,
`image_2` mediumblob,
`content_3` text COLLATE utf8_unicode_ci,
`image_3` mediumblob,
`content_4` text COLLATE utf8_unicode_ci,
`image_4` mediumblob,
// Images and content areas go on for 17 of each
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;