Вы можете попробовать это:
{{ v.docs.0 }}
Как arr.0
Вы можете получить элементы по индексу (0
, 1
, 2
и т. Д.).
вы можете посмотреть первые несколько байтов и выяснить это для наиболее распространенных типов файлов
Вы можете использовать функцию FindMimeFromData () в UrlMon.dll (используя pinvoke).
См. эту страницу для примера и эту страницу MSDN для документация функции.
Не сохранять его ни в каком виде. Сохраните его как файл без расширения. Если вы не знаете, что это, не притворяйтесь. Если приложение, которое его сохранило, запрашивает его, верните его из файловой системы таким же образом, как и из базы данных; как двоичные данные. Базе данных не важно, какой тип данных представляет собой двоичный объект; Вы тоже не должны.
Вы можете попробовать использовать TriD http://mark0.net/soft-trid-e.html
Он просканирует файлы и попытается определить расширение.
Another option would be to physically partition your database. You could store the table that contains the blob field in a different database file that could be stored on a different hard disk/spindle. The disk that contains the blob table could be further optimized by making it RAID 0 or RAID 10.
This could speed things up. Also, this approach eliminates the need to change the application logic.
Откуда вы знаете, что эта информация доступна для чтения людям? Цели расширений файлов
- связать определенное программное обеспечение для открытия файла, чтобы при двойном щелчке по файлу .txt блокнот .exe обрабатывает их.
Если вы записываете их в файловую систему только для разгрузки базы данных, то в каком-либо конкретном расширении нет необходимости. Если вы хотите связать с ним программу, используйте соответствующее расширение
In your words "... I've been tasked with ..." - are you sure this is not a problem that can be solved by performing some optimisation on the database? Going down the path of hacking a legacy application for which you don't have the source code and for which there is no support is something that you want to avoid as much as possible.
So, look at the problem here - slowness of the application. So why is it slow? Something a database index couldn't solve?
If you have to extract the BLOBs to the filesystem, then why is the format of the file relevant? Surely the application is designed to do a query on the database in order to get the file anyway--how would extracting the BLOBs to the filesystem help you?
As an aside though - I usually use the Unix file
command to identify files through magic numbers.